System.CodeDom.Compiler.CodeDomProvider Class

Assembly: System.dll
Namespace: System.CodeDom.Compiler
Summary
Provides a base class for CodeDomProvider implementations. This class is abstract.
C# Syntax:
public abstract class CodeDomProvider : Component
Remarks
A CodeDomProvider can be used to create and retrieve instances of code generators and code compilers. Code generators can be used to generate code in a particular language, and code compilers can be used to compile executables.
See also:
System.CodeDom.Compiler Namespace

System.CodeDom.Compiler.CodeDomProvider Member List:

Public Properties
Container
(inherited from System.ComponentModel.Component)
Read-only

See base class member description: System.ComponentModel.Component.Container


Gets the IContainer that contains the Component.
FileExtension Read-only

Gets or sets the default file name extension to use for source code files in the current language.
LanguageOptions Read-only

Gets or sets a language features identifier.
Site
(inherited from System.ComponentModel.Component)
Read-write

See base class member description: System.ComponentModel.Component.Site


Gets or sets the ISite of the Component.
Public Methods
CreateCompiler Creates a new code compiler.
CreateGenerator Overloaded:
CreateGenerator()

Creates a new code generator.
CreateGenerator Overloaded:
CreateGenerator(string fileName)

Creates a new code generator using the specified file name for output.
CreateGenerator Overloaded:
CreateGenerator(TextWriter output)

Creates a new code generator using the specified TextWriter for output.
CreateObjRef
(inherited from System.MarshalByRefObject)
See base class member description: System.MarshalByRefObject.CreateObjRef


Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
CreateParser Creates a new code parser.
Dispose
(inherited from System.ComponentModel.Component)
Overloaded:
Dispose()

See base class member description: System.ComponentModel.Component.Dispose


Releases all resources used by the Component.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetLifetimeService
(inherited from System.MarshalByRefObject)
See base class member description: System.MarshalByRefObject.GetLifetimeService


Retrieves the current lifetime service object that controls the lifetime policy for this instance.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
InitializeLifetimeService
(inherited from System.MarshalByRefObject)
See base class member description: System.MarshalByRefObject.InitializeLifetimeService


Obtains a lifetime service object to control the lifetime policy for this instance.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Public Events
Disposed
(inherited from System.ComponentModel.Component)
See base class member description: System.ComponentModel.Component.Disposed


Adds an event handler to listen to the Component.Disposed event on the component.
Protected Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Protected Properties
DesignMode
(inherited from System.ComponentModel.Component)
Read-only

See base class member description: System.ComponentModel.Component.DesignMode


Gets a value that indicates whether the Component is currently in design mode.
Events
(inherited from System.ComponentModel.Component)
Read-only

See base class member description: System.ComponentModel.Component.Events


Gets the list of event handlers that are attached to this Component.
Protected Methods
Dispose
(inherited from System.ComponentModel.Component)
Overloaded:
Dispose(bool disposing)

See base class member description: System.ComponentModel.Component.Dispose


Releases the unmanaged resources used by the Component and optionally releases the managed resources.
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
GetService
(inherited from System.ComponentModel.Component)
See base class member description: System.ComponentModel.Component.GetService


Returns an object that represents a service provided by the Component or by its Container.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.CodeDom.Compiler.CodeDomProvider Member Details

ctor #1
Summary:
Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
protected CodeDomProvider();

Return to top


Property: Container (read-only)
Inherited
See base class member description: System.ComponentModel.Component.Container

Summary
Gets the IContainer that contains the Component.
C# Syntax:
public IContainer Container {get;}
Remarks
The components in a container are tracked in a first-in, first-out list, which also defines the order of the components within the container. The last component added is the last component in the list.
See also:
IContainer | Container

Return to top


Property: DesignMode (read-only)
Inherited
See base class member description: System.ComponentModel.Component.DesignMode

Summary
Gets a value that indicates whether the Component is currently in design mode.
C# Syntax:
protected bool DesignMode {get;}
Remarks
The design mode indicator is stored in the ISite; therefore, if the Component does not have an ISite associated with it, this property is always false.
See also:
IContainer | Container | ISite

Return to top


Property: Events (read-only)
Inherited
See base class member description: System.ComponentModel.Component.Events

Summary
Gets the list of event handlers that are attached to this Component.
C# Syntax:
protected EventHandlerList Events {get;}
Remarks
For more information about handling events, see the conceptual topic at MSDN: eventsoverview.
See also:
EventHandlerList

Return to top


Property: FileExtension (read-only)
Summary
Gets or sets the default file name extension to use for source code files in the current language.
C# Syntax:
public virtual string FileExtension {get;}
Remarks
This property is used by code generators and code compilers to indicate what file extensions should be generated or used.

Return to top


Property: LanguageOptions (read-only)
Summary
Gets or sets a language features identifier.
C# Syntax:
public virtual LanguageOptions LanguageOptions {get;}

Return to top


Property: Site (read-write)
Inherited
See base class member description: System.ComponentModel.Component.Site

Summary
Gets or sets the ISite of the Component.
C# Syntax:
public virtual ISite Site {get; set;}
Implements:
IComponent.Site
Remarks
A Component will have an ISite if it has been added to an IContainer and the IContainer assigns an ISite to it. The IContainer is responsible to assign the ISite to the Component. Changing the value of the component's ISite does not necessarily change the name of the site the Component is assigned to. It is strongly suggested that the setting of the Component.Site property only be done by an IContainer.

The property value is null if the Component is removed from its IContainer. Assigning null to this property does not necessarily remove the Component from the IContainer.

A Component might or might not have a name. If a Component is given a name, the name must be unique among other Component objects within its IContainer. The ISite stores the name of the Component; therefore, you can only name a Component if it has an ISite associated with it.

See also:
IContainer | Container | ISite

Return to top


Method: CreateCompiler()
Summary
Creates a new code compiler.
C# Syntax:
public abstract ICodeCompiler CreateCompiler();
Return Value:
An ICodeCompiler that can be used for compilation of System.CodeDom based source code representations.

Return to top


Overloaded Method: CreateGenerator()
Summary
Creates a new code generator.
C# Syntax:
public abstract ICodeGenerator CreateGenerator();
Return Value:
An ICodeGenerator that can be used to generate System.CodeDom based source code representations.

Return to top


Overloaded Method: CreateGenerator(
   string fileName
)
Summary
Creates a new code generator using the specified file name for output.
C# Syntax:
public virtual ICodeGenerator CreateGenerator(
   string fileName
);
Parameters:

fileName

The file name to output to.

Return Value:
An ICodeGenerator that can be used to generate System.CodeDom based source code representations.
Remarks
This method uses the specified file name for output.

Return to top


Overloaded Method: CreateGenerator(
   TextWriter output
)
Summary
Creates a new code generator using the specified TextWriter for output.
C# Syntax:
public virtual ICodeGenerator CreateGenerator(
   TextWriter output
);
Parameters:

output

A TextWriter to use to output.

Return Value:
An ICodeGenerator that can be used to generate System.CodeDom based source code representations.
Remarks
This method uses the specified TextWriter for output. This method supports more optimized code generation that incrementally updates the source code.
See also:
TextWriter

Return to top


Method: CreateObjRef(
   Type requestedType
)
Inherited
See base class member description: System.MarshalByRefObject.CreateObjRef

Summary
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
C# Syntax:
public virtual ObjRef CreateObjRef(
   Type requestedType
);
Parameters:

requestedType

The Type of the object that the new ObjRef will reference.

Return Value:
Information required to generate a proxy.
Exceptions
Exception Type Condition
RemotingException This instance is not a valid remoting object.

Return to top


Method: CreateParser()
Summary
Creates a new code parser.
C# Syntax:
public virtual ICodeParser CreateParser();
Return Value:
An ICodeParser that can be used to parse source code.

Return to top


Overloaded Method: Dispose()
Inherited
See base class member description: System.ComponentModel.Component.Dispose

Summary
Releases all resources used by the Component.
C# Syntax:
public void Dispose();
Implements:
IDisposable.Dispose
Remarks
Calling Component.Dispose allows the resources used by the Component to be reallocated for other purposes. For more information about Component.Dispose, see the conceptual topic at MSDN: cleaningupunmanagedresources.
See also:
IContainer | Container

Return to top


Overloaded Method: Dispose(
   bool disposing
)
Inherited
See base class member description: System.ComponentModel.Component.Dispose

Summary
Releases the unmanaged resources used by the Component and optionally releases the managed resources.
C# Syntax:
protected virtual void Dispose(
   bool disposing
);
Parameters:

disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks
This method is called by the public Dispose method and the Object.Finalize method.Dispose() invokes the protected Dispose(Boolean) method with the disposing parameter set to true. Object.Finalize invokes Dispose with disposing set to false.

When the disposing parameter is true, this method releases all resources held by any managed objects that this Component references. This method invokes the Dispose() method of each referenced object.



Notes to inheritors: Dispose can be called multiple times by other objects. When overriding Dispose(Boolean), be careful not to reference objects that have been previously disposed of in an earlier call to Dispose. For more information about how to implement Dispose(Boolean), see the conceptual topic at MSDN: implementingdisposemethod.

For more information about Dispose and Object.Finalize, see the conceptual topic at MSDN: cleaningupunmanagedresources and the conceptual topic at MSDN: overridingfinalizemethod.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CodeDomProvider();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetLifetimeService()
Inherited
See base class member description: System.MarshalByRefObject.GetLifetimeService

Summary
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
C# Syntax:
public object GetLifetimeService();
Return Value:
An object of type ILease used to control the lifetime policy for this instance.
Remarks
For more information about lifetime services, see the LifetimeServices class.

Return to top


Method: GetService(
   Type service
)
Inherited
See base class member description: System.ComponentModel.Component.GetService

Summary
Returns an object that represents a service provided by the Component or by its Container.
C# Syntax:
protected virtual object GetService(
   Type service
);
Parameters:

service

A service provided by the Component.

Return Value:
An Object that represents a service provided by the Component.

This value is null if the Component does not provide the specified service.

Remarks
This method can be overridden by a derived class.
See also:
IContainer | Container | ISite | IServiceProvider

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: InitializeLifetimeService()
Inherited
See base class member description: System.MarshalByRefObject.InitializeLifetimeService

Summary
Obtains a lifetime service object to control the lifetime policy for this instance.
C# Syntax:
public virtual object InitializeLifetimeService();
Return Value:
An object of type ILease used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the LifetimeServices.LeaseManagerPollTime property.
Remarks
For more information about lifetime services, see the LifetimeServices class.
Example
The following code example demonstrates creating a lease.
 public class MyClass : MarshalByRefObject
 {
   public override Object InitializeLifetimeService()
   {
     ILease lease = (ILease)base.InitializeLifetimeService();
     if (lease.CurrentState == LeaseState.Initial)
     {
          lease.InitialLeaseTime = TimeSpan.FromMinutes(1);
          lease.SponsorshipTimeout = TimeSpan.FromMinutes(2);
           lease.RenewOnCallTime = TimeSpan.FromSeconds(2);
     }
       return lease;
   }
 }

    

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Event: Disposed
Inherited
See base class member description: System.ComponentModel.Component.Disposed

Summary
Adds an event handler to listen to the Component.Disposed event on the component.
C# Syntax:
public event EventHandler Disposed;
Remarks
When you create a Component.Disposed delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about the event handler delegates, see the conceptual topic at MSDN: eventsdelegates.
See also:
EventHandler

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.