Share via


TypeDescription Class

Represents a description of a Type class that contains a collection of attribute descriptions. The Type represents type declarations: class types, interface types, array types, value types, and enumeration types.

Namespace: Microsoft.MetadirectoryServices
Assembly: Microsoft.MetadirectoryServicesEx (in Microsoft.MetadirectoryServicesEx.dll)

Usage

'Usage
Dim instance As TypeDescription

Syntax

'Declaration
Public MustInherit Class TypeDescription
public abstract class TypeDescription
public ref class TypeDescription abstract
public abstract class TypeDescription
public abstract class TypeDescription

Example

The following example declares a TypeDescriptionCollection.

Imports Microsoft.MetadirectoryServices
Imports System.IO
Imports System.Xml

Public Class NextGenMACDextensionObject
    Implements IMAExtensibleFileImport
    Dim tabchar As String = ControlChars.Tab
    Dim CRLFchar As String = ControlChars.CrLf


    Public Sub GenerateImportFile(ByVal fileName As String, ByVal connectTo As String, ByVal user As String, ByVal password As String, ByVal configParameters As Microsoft.MetadirectoryServices.ConfigParameterCollection, ByVal fFullImport As Boolean, ByVal types As Microsoft.MetadirectoryServices.TypeDescriptionCollection, ByRef customData As String) Implements Microsoft.MetadirectoryServices.IMAExtensibleFileImport.GenerateImportFile

        ' Declarations

        ' Move the file settings down to after you read the config parameters.
        Dim importFile As StreamWriter = New StreamWriter(fileName)

        Dim MyFile As StreamWriter = New StreamWriter(configParameters("path").Value & "\params.txt")
        Dim ConfigParam As ConfigParameter
        Dim AttrDesc As AttributeDescription
        Dim TypeDesc As TypeDescription
        Dim inFileName As String

        ' This code writes config params before it does anything else.
        Try

            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("Configuration parameters for NextGen MA written " & Now())
            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("This is the start of the configuration parameters for the NextGen MA")
            MyFile.WriteLine("")
            MyFile.WriteLine("Writing static parameters now")
            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("File name = " & fileName)
            MyFile.WriteLine("Connect to = " & connectTo)
            MyFile.WriteLine("User = " & user)
            MyFile.WriteLine("Password (DON'T DO THIS) = " & password)

            ' Go through config parameters string array.

            MyFile.WriteLine("")
            MyFile.WriteLine("Writing additional parameter array now")
            MyFile.WriteLine("-----------------------------------------------------------------------")
            For Each ConfigParam In configParameters
                MyFile.Write(ConfigParam.Name & " = ")
                If ConfigParam.IsEncrypted Then

                    ' Don't write the value of encrypted config parameters to the file like this.
                    MyFile.WriteLine("encrypted parameter (DON'T DO THIS) = " & ConfigParam.Value)
                Else

                    ' Write the value to the file.
                    MyFile.WriteLine(ConfigParam.Value)
                End If
            Next

            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("end of configuration parameters section")
            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("")
            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("Writing import run step type")
            MyFile.WriteLine("-----------------------------------------------------------------------")

            If fFullImport Then

                ' Doing a full import now.
                inFileName = configParameters("path").Value & "\" & configParameters("fullfile").Value
                MyFile.WriteLine("Doing a full import reading XML file " & inFileName)
            Else

                ' Doing a delta import.
                inFileName = configParameters("path").Value & "\" & configParameters("deltafile").Value
                MyFile.WriteLine("Doing a delta import reading XML file " & inFileName)
            End If
            MyFile.WriteLine("-----------------------------------------------------------------------")

            ' Now write the schema to the file with each attribute indented under its type.
            MyFile.WriteLine("Writing CS schema to file")
            MyFile.WriteLine("-----------------------------------------------------------------------")

            ' Write the schema's object type attribute name.
            MyFile.WriteLine("Number of object types in schema: " & types.Count & ", object type attribute name is:" & types.ObjectTypeAttributeName)


            ' Now write the object types and corresponding attributes.
            For Each TypeDesc In types

                'write each object type name
                MyFile.WriteLine(TypeDesc.Name)

                ' Write anchor attribute definition heading.
                MyFile.Write(tabchar & "Anchor attribute list:")

                For Each AttrDesc In TypeDesc.AnchorAttributes

                    ' Write information about the anchor attributes.
                    MyFile.WriteLine(tabchar & tabchar & AttrDesc.Name)
                Next
                MyFile.WriteLine("")

                ' Iterate through the attributes defined for this type.
                For Each AttrDesc In TypeDesc.Attributes

                    ' Write the attribute information.
                    MyFile.WriteLine(tabchar & AttrDesc.Name & ", type is: " & AttrDesc.DataType.ToString & ", is anchor: " & AttrDesc.IsAnchor & ", is multi-valued: " & AttrDesc.IsMultiValued)
                Next
            Next

            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("Done writing schema")
            MyFile.WriteLine("-----------------------------------------------------------------------")
            MyFile.WriteLine("Closing file")
            MyFile.Close()

        Catch ex As Exception
            Throw New UnexpectedDataException("Exception while writing confuration data to params.txt" & CRLFchar & ex.Message & CRLFchar & ex.StackTrace)

        End Try
    End Sub
End Class

Remarks

Each TypeDescription object contains a collection of attributes and a collection of anchor attributes that are associated to the data source management agent (MA) extension. Attributes and anchor attributes are represented as a AttributeDescriptionCollection of attribute objects. Each attribute object in the collection is represented as an AttributeDescription object. To get the attributes on an object—for example, through the WriteLine method—you must declare the TypeDescriptionCollection to have access to the AttributeDescription objects. The following code example demonstrates how to do this.

Inheritance Hierarchy

System.Object
  Microsoft.MetadirectoryServices.TypeDescription

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Target Platforms

Change History

See Also

Reference

TypeDescription Members
Microsoft.MetadirectoryServices Namespace
Type
Microsoft.MetadirectoryServices