System.Runtime.Remoting.MetadataServices.MetaData Class

Assembly: System.Runtime.Remoting.dll
Namespace: System.Runtime.Remoting.MetadataServices
Summary
Provides methods that allow you to work with XML schema.
C# Syntax:
public class MetaData
Remarks
The MetaData class provides methods that allow you to generate Web Services Description Language (WSDL) from type information, convert an XML Schema into a code stream, and compile the code stream into an assembly. This functionality is also present in the .
See also:
System.Runtime.Remoting.MetadataServices Namespace

System.Runtime.Remoting.MetadataServices.MetaData Member List:

Public Constructors
ctor #1 Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Public Methods
ConvertCodeSourceFileToAssemblyFile Compiles a specified code source file into a run-time assembly file.
ConvertCodeSourceStreamToAssemblyFile Compiles specified code source streams into a run-time assembly file.
ConvertSchemaStreamToCodeSourceStream Overloaded:
ConvertSchemaStreamToCodeSourceStream(bool clientProxy, string outputDirectory, Stream inputStream, ArrayList outCodeStreamList)

Converts the specified schema definition into C# proxy source code.
ConvertSchemaStreamToCodeSourceStream Overloaded:
ConvertSchemaStreamToCodeSourceStream(bool clientProxy, string outputDirectory, Stream inputStream, ArrayList outCodeStreamList, string proxyUrl)

Converts the specified schema definition into C# proxy source code for a remote object located at the specified URL.
ConvertSchemaStreamToCodeSourceStream Overloaded:
ConvertSchemaStreamToCodeSourceStream(bool clientProxy, string outputDirectory, Stream inputStream, ArrayList outCodeStreamList, string proxyUrl, string proxyNamespace)

Converts the specified schema definition into C# proxy source code for a remote object located at the specified URL and in the provided class namespace.
ConvertTypesToSchemaToFile Overloaded:
ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, string path)

Converts the specified service types to XML schema, and writes it to a file specified by name.
ConvertTypesToSchemaToFile Overloaded:
ConvertTypesToSchemaToFile(Type[] types, SdlType sdlType, string path)

Converts the specified object types to XML schema, and writes it to a file specified by name.
ConvertTypesToSchemaToStream Overloaded:
ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)

Converts the specified service types to XML schema, and writes it to a specified stream.
ConvertTypesToSchemaToStream Overloaded:
ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream)

Converts the specified object types to XML schema, and writes it to a specified stream.
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.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
RetrieveSchemaFromUrlToFile Downloads the XML schema from a URL, and writes it to the specified file.
RetrieveSchemaFromUrlToStream Downloads the XML schema from a URL, and writes it to the specified stream.
SaveStreamToFile Saves the input stream to a file with the specified name.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

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

Derived from System.Object, the primary base class for all objects.
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.Runtime.Remoting.MetadataServices.MetaData Member Details

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

Return to top


Method: ConvertCodeSourceFileToAssemblyFile(
   string codePath,
   string assemblyPath,
   string strongNameFilename
)
Summary
Compiles a specified code source file into a run-time assembly file.
C# Syntax:
public static void ConvertCodeSourceFileToAssemblyFile(
   string codePath,
   string assemblyPath,
   string strongNameFilename
);
Parameters:

codePath

The path to the file containing the source code.

assemblyPath

The location where the new run-time assembly is generated.

strongNameFilename

The strong name to compile into the new assembly. Can be String.Empty.

Remarks
For additional information on strong names, see the conceptual topic at MSDN: Strong-Named Assemblies.

Note If a file with the specified name already exists, it is overwritten.
Example
The following code example demonstrates the use of the MetaData.ConvertCodeSourceFileToAssemblyFile method to write the schema definition of the specified types to a runtime assembly with the specified name. The CsSource.cs file converted here contains C# source code.
using System;
using System.Runtime.Remoting.MetadataServices;


public class Test
{
   public static void Main()
   {
      MetaData.ConvertCodeSourceFileToAssemblyFile("CsSource.cs", "testAssm.dll", "");
   }
}

    

Return to top


Method: ConvertCodeSourceStreamToAssemblyFile(
   ArrayList outCodeStreamList,
   string assemblyPath,
   string strongNameFilename
)
Summary
Compiles specified code source streams into a run-time assembly file.
C# Syntax:
public static void ConvertCodeSourceStreamToAssemblyFile(
   ArrayList outCodeStreamList,
   string assemblyPath,
   string strongNameFilename
);
Parameters:

outCodeStreamList

An ArrayList of streams with the source code.

assemblyPath

The location where the new run-time assembly is generated.

strongNameFilename

The strong name to compile into the new run-time assembly. Can be String.Empty.

Remarks
For additional information on strong names, see the conceptual topic at MSDN: Strong-Named Assemblies.

Note If a file with the specified name already exists, it is overwritten.

Return to top


Overloaded Method: ConvertSchemaStreamToCodeSourceStream(
   bool clientProxy,
   string outputDirectory,
   Stream inputStream,
   ArrayList outCodeStreamList
)
Summary
Converts the specified schema definition into C# proxy source code.
C# Syntax:
public static void ConvertSchemaStreamToCodeSourceStream(
   bool clientProxy,
   string outputDirectory,
   Stream inputStream,
   ArrayList outCodeStreamList
);
Parameters:

clientProxy

Indicates the type of proxy to generate. If true, generates a simple proxy (also known as wrapped proxy) that automatically loads the channels, exposes all the methods of the remote object, and provides access to the channel properties. If false, generates a transparent proxy that exposes all the methods of the remote object.

outputDirectory

The directory where the new C# source code files with the proxy are created.

inputStream

The input stream containing the schema definition in Web Services Description Language (WSDL) format.

outCodeStreamList

The list of file names for the code streams that are generated. Note that the MetaData.ConvertSchemaStreamToCodeSourceStream method can create multiple source code streams.

Remarks


Note If files with the specified names already exist, they are overwritten.

Return to top


Overloaded Method: ConvertSchemaStreamToCodeSourceStream(
   bool clientProxy,
   string outputDirectory,
   Stream inputStream,
   ArrayList outCodeStreamList,
   string proxyUrl
)
Summary
Converts the specified schema definition into C# proxy source code for a remote object located at the specified URL.
C# Syntax:
public static void ConvertSchemaStreamToCodeSourceStream(
   bool clientProxy,
   string outputDirectory,
   Stream inputStream,
   ArrayList outCodeStreamList,
   string proxyUrl
);
Parameters:

clientProxy

Indicates the type of proxy to generate. If true, generates a simple proxy (also known as wrapped proxy) that automatically loads the channels, exposes all the methods of the remote object, and provides access to the channel properties. If false, generates a transparent proxy that exposes all the methods of the remote object.

outputDirectory

The directory where the new C# source code files with the proxy are created.

inputStream

The input stream containing the schema definition in Web Services Description Language (WSDL) format.

outCodeStreamList

The list of file names for the code streams that are generated. Note that the MetaData.ConvertSchemaStreamToCodeSourceStream method can create multiple source code streams.

proxyUrl

The URL where the target remote object represented by the new proxy will be located.

Remarks


Note If files with the specified names already exist, they are overwritten.

Return to top


Overloaded Method: ConvertSchemaStreamToCodeSourceStream(
   bool clientProxy,
   string outputDirectory,
   Stream inputStream,
   ArrayList outCodeStreamList,
   string proxyUrl,
   string proxyNamespace
)
Summary
Converts the specified schema definition into C# proxy source code for a remote object located at the specified URL and in the provided class namespace.
C# Syntax:
public static void ConvertSchemaStreamToCodeSourceStream(
   bool clientProxy,
   string outputDirectory,
   Stream inputStream,
   ArrayList outCodeStreamList,
   string proxyUrl,
   string proxyNamespace
);
Parameters:

clientProxy

Indicates the type of proxy to generate. If true, generates a simple proxy (also known as wrapped proxy) that automatically loads the channels, exposes all the methods of the remote object, and provides access to the channel properties. If false, generates a transparent proxy that exposes all the methods of the remote object.

outputDirectory

The directory where the new C# source code files with the proxy are created.

inputStream

The input stream containing the schema definition in Web Services Description Language (WSDL) format.

outCodeStreamList

The list of file names for the code streams that are generated. Note that the MetaData.ConvertSchemaStreamToCodeSourceStream method can create multiple source code streams.

proxyUrl

The URL where the target remote object represented by the new proxy will be located.

proxyNamespace

The namespace of the newly created proxy.

Remarks


Note If files with the specified names already exist, they are overwritten.

Return to top


Overloaded Method: ConvertTypesToSchemaToFile(
   ServiceType[] types,
   SdlType sdlType,
   string path
)
Summary
Converts the specified service types to XML schema, and writes it to a file specified by name.
C# Syntax:
public static void ConvertTypesToSchemaToFile(
   ServiceType[] types,
   SdlType sdlType,
   string path
);
Parameters:

types

The ServiceType instances to convert to XML schema.

sdlType

The type of service description language to use for the XML schema.

path

The path of the XML file.

Remarks
A ServiceType instance allows you to associate a URL with an object Type.

Note If a file with the specified name already exists, it is overwritten.

Return to top


Overloaded Method: ConvertTypesToSchemaToFile(
   Type[] types,
   SdlType sdlType,
   string path
)
Summary
Converts the specified object types to XML schema, and writes it to a file specified by name.
C# Syntax:
public static void ConvertTypesToSchemaToFile(
   Type[] types,
   SdlType sdlType,
   string path
);
Parameters:

types

The object types to convert to XML schema.

sdlType

The type of service description language to use for the XML schema.

path

The path of the XML file.

Remarks


Note If a file with the specified name already exists, it is overwritten.
Example
The following code example demonstrates the use of the MetaData.ConvertTypesToSchemaToFile method to write the schema definition of the specified types to a file.
using System;
using System.Runtime.Remoting.Metadata;
using System.Runtime.Remoting.MetadataServices;

public class Test {

   class TestClass {
      int integer;
      public double dFloatingPoint = 5.1999;

      public int Int {
         get { return integer; }
         set { integer = value; }
      }

      public void Print () {
         Console.WriteLine("The double is equal to {0}.", dFloatingPoint);
      }
   }
   

   public static void Main() {

      Type[] types = new Type[4];

      String s = "a";
      int i = -5;
      double d = 3.1415;
      TestClass tc = new TestClass();

      types[0] = s.GetType();
      types[1] = i.GetType();
      types[2] = d.GetType();
      types[3] = tc.GetType();

      MetaData.ConvertTypesToSchemaToFile(types, SdlType.Wsdl, "test.xml");
   }
}

    

Return to top


Overloaded Method: ConvertTypesToSchemaToStream(
   ServiceType[] serviceTypes,
   SdlType sdlType,
   Stream outputStream
)
Summary
Converts the specified service types to XML schema, and writes it to a specified stream.
C# Syntax:
public static void ConvertTypesToSchemaToStream(
   ServiceType[] serviceTypes,
   SdlType sdlType,
   Stream outputStream
);
Parameters:

serviceTypes

The ServiceType instances to convert to XML schema.

sdlType

The type of service description language to use for the XML schema.

outputStream

The Stream the schema is written to.

Remarks
A ServiceType instance allows you to associate a URL with an object Type.

Return to top


Overloaded Method: ConvertTypesToSchemaToStream(
   Type[] types,
   SdlType sdlType,
   Stream outputStream
)
Summary
Converts the specified object types to XML schema, and writes it to a specified stream.
C# Syntax:
public static void ConvertTypesToSchemaToStream(
   Type[] types,
   SdlType sdlType,
   Stream outputStream
);
Parameters:

types

The object types to convert to XML schema.

sdlType

The type of service description language to use for the XML schema.

outputStream

The Stream the schema is written to.

Example
The following code example demonstrates the use of the MetaData.ConvertTypesToSchemaToStream method to write the schema definition of the specified types to a stream.
using System;
using System.Runtime.Remoting.Metadata;
using System.Runtime.Remoting.MetadataServices;
using System.IO;

public class Test {

   class TestClass {
      int integer;
      public double dFloatingPoint = 5.1999;

      public int Int {
         get { return integer; }
         set { integer = value; }
      }

      public void Print () {
         Console.WriteLine("The double is equal to {0}.", dFloatingPoint);
      }
   }
   

   public static void Main() {

      Type[] types = new Type[4];

      String s = "a";
      int i = -5;
      double d = 3.1415;
      TestClass tc = new TestClass();

      types[0] = s.GetType();
      types[1] = i.GetType();
      types[2] = d.GetType();
      types[3] = tc.GetType();

      FileStream fs = new FileStream("test.xml", FileMode.OpenOrCreate);
      MetaData.ConvertTypesToSchemaToStream(types, SdlType.Wsdl, fs);
   }
}

    

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:
~MetaData();

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: 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: 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: RetrieveSchemaFromUrlToFile(
   string url,
   string path
)
Summary
Downloads the XML schema from a URL, and writes it to the specified file.
C# Syntax:
public static void RetrieveSchemaFromUrlToFile(
   string url,
   string path
);
Parameters:

url

The URL where the XML schema is located.

path

The path of the file the schema is written to.

Remarks


Note If a file with the specified name already exists, it is overwritten.

Return to top


Method: RetrieveSchemaFromUrlToStream(
   string url,
   Stream outputStream
)
Summary
Downloads the XML schema from a URL, and writes it to the specified stream.
C# Syntax:
public static void RetrieveSchemaFromUrlToStream(
   string url,
   Stream outputStream
);
Parameters:

url

The URL where the XML schema is located.

outputStream

The Stream the schema is written to.

Return to top


Method: SaveStreamToFile(
   Stream inputStream,
   string path
)
Summary
Saves the input stream to a file with the specified name.
C# Syntax:
public static void SaveStreamToFile(
   Stream inputStream,
   string path
);
Parameters:

inputStream

The stream to write to the specified file.

path

The file the input stream is written to.

Remarks


Note If a file with the specified name already exists, it is overwritten.

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


Top of page

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