This documentation is archived and is not being maintained.

SoapExtension.GetInitializer Method

When overridden in a derived class, allows a SOAP extension to initialize data specific to an XML Web service method at a one time performance cost.

Overload List

When overridden in a derived class, allows a SOAP extension to initialize data specific to a class implementing an XML Web service at a one time performance cost.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public MustOverride Function GetInitializer(Type) As Object
[C#] public abstract object GetInitializer(Type);
[C++] public: virtual Object* GetInitializer(Type*) = 0;
[JScript] public abstract function GetInitializer(Type) : Object;

When overridden in a derived class, allows a SOAP extension to initialize data specific to an XML Web service method using an attribute applied to the XML Web service method at a one time performance cost.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public MustOverride Function GetInitializer(LogicalMethodInfo, SoapExtensionAttribute) As Object
[C#] public abstract object GetInitializer(LogicalMethodInfo, SoapExtensionAttribute);
[C++] public: virtual Object* GetInitializer(LogicalMethodInfo*, SoapExtensionAttribute*) = 0;
[JScript] public abstract function GetInitializer(LogicalMethodInfo, SoapExtensionAttribute) : Object;

Example

[Visual Basic, C#, C++] The following code demonstrates how you can obtain SOAP extension-specific data passed in using a class that derives from SoapExtensionAttribute, and then cache that data in GetInitializer. This code example is part of a full code example for a TraceExtension SOAP extension that can be found in the SoapExtension class overview. This code example relies on a TraceExtensionAttribute being passed into the attribute parameter. In the full code example, TraceExtensionAttribute derives from SoapExtensionAttribute and adds a Filename property, which is what GetInitializer stores in the cache.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of GetInitializer. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
' When the SOAP extension is accessed for the first time, 
' cache the file name passed in by the SoapExtensionAttribute.

Public Overloads Overrides Function GetInitializer( _
    methodInfo As LogicalMethodInfo, _
    attribute As SoapExtensionAttribute) As Object    
    Return CType(attribute, TraceExtensionAttribute).Filename
End Function

[C#] 
// When the SOAP extension is accessed for the first time, cache the 
// file name passed in by the SoapExtensionAttribute.    
public override object GetInitializer(LogicalMethodInfo methodInfo,
    SoapExtensionAttribute attribute) 
{
    return ((TraceExtensionAttribute) attribute).Filename;
}

[C++] 
// When the SOAP extension is accessed for the first time, cache the 
// file name passed in by the SoapExtensionAttribute.    
public:
Object* GetInitializer(LogicalMethodInfo* /*methodInfo*/,
   SoapExtensionAttribute* attribute) 
{
   return (dynamic_cast<TraceExtensionAttribute*> (attribute))->Filename;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

SoapExtension Class | SoapExtension Members | System.Web.Services.Protocols Namespace

Show: