NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ICodeSourceFile Interface

Provides a logical representation of a single source file.

ICodeSourceFile

[Visual Basic]
Public Interface ICodeSourceFile
[C#]
public interface ICodeSourceFile
[C++]
public __gc __interface ICodeSourceFile

[JScript] In JScript, you can use the interfaces in the NGWS frameworks, but you cannot define your own.

Remarks

A source file can contain many logical elements. These elements normally consist of classes, interfaces, and other top level constructs. When walking the object model of a file you will normally start with a specific class. You can either access the Elements collection and look for a specific class, or use the FindPublicClasses function to retrieve the list of public classes contained in this file. Note: ClassForName should not be used to access the ICodeClass for a class in the current file. For more information see the System.ComponentModel.Design.CodeModel.ClassForName method. Editing the Object Model Creating complex statements is accomplished by composing together the various expressions. In addition there are method, data member, and other editing functions on ICodeClass.

The places in the object model that take Object value as an argument can take any of the following:

Literal Syntax Actual value. This would be persisted in code as the number or string that you passed in, with the correct language syntax.
ICodeArrayCreateExpression A creation of an array. Contains the type of the array and an array of "values".
ICodeObjectCreateExpression A creation of an array. Contains the type of the object to construct and an array of "values" that will be used as arguments to the constructor of that class.
ICodeMethodInvokeExpression Invokes a method on some object. Contains the name of the object and method to invoke, and an array of "values" that will be used as arguments to the methods.
ICodeNameReferenceExpression Reference to some object or value in the namespace of this class. This can be both static references to fields, and references to other members in this class. This contains a simple string.

Requirements

Namespace: System.ComponentModel.Design.CodeModel

Assembly: System.dll

Example

An example of how to represent complex code statements using the ICodeSourceFile interface:

// SafeC source to generate
    foo = new Control[] { new Button("caption"), button1 };

    // Objects to create to represent the right side of the equals
    ICodeArrayCreateExpression ( Button.class,
    new Object[] {
 ICodeObjectCreateExpression ( "caption" ),
    ICodeNameReferenceExpression ( "button1 " )
    } )

See Also

ICodeSourceFile Members | System.ComponentModel.Design.CodeModel Namespace | ICodeClass | ICodeArrayCreateExpression | ICodeObjectCreateExpression | ICodeMethodInvokeExpression | ICodeNameReferenceExpression | ICodeClass | ICodeArrayCreateExpression | ICodeObjectCreateExpression | ICodeMethodInvokeExpression | ICodeNameReferenceExpression