Specifies a particular context provider export.

Namespace: Hypertable.Composition
Assembly: ht4n (in ht4n.dll) Version: 0.9.8.11 (0.9.8.11)

Syntax

         
 C#  Visual Basic  Visual C++ 
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)]
[MetadataAttributeAttribute]
public sealed class ExportContextProviderAttribute : ExportAttribute, 
	IContextProviderMetadata
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False)> _
<MetadataAttributeAttribute> _
Public NotInheritable Class ExportContextProviderAttribute _
	Inherits ExportAttribute _
	Implements IContextProviderMetadata
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false)]
[MetadataAttributeAttribute]
public ref class ExportContextProviderAttribute sealed : public ExportAttribute, 
	IContextProviderMetadata

Members

            
 All Members  Constructors   Properties   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
ExportContextProviderAttribute(String)
Initializes a new instance of the ExportContextProviderAttribute class.
ContractName
Gets the contract name that is used to export the type or member marked with this attribute.
(Inherited from ExportAttribute.)
ContractType
Gets the contract type that is exported by the member that this attribute is attached to.
(Inherited from ExportAttribute.)
Equals(Object)
Returns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute.)
GetHashCode()()()()
Returns the hash code for this instance.
(Inherited from Attribute.)
GetType()()()()
Gets the Type of the current instance.
(Inherited from Object.)
IsDefaultAttribute()()()()
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute.)
Match(Object)
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute.)
ProviderName
Gets the context provider name.
ToString()()()()
Returns a string that represents the current object.
(Inherited from Object.)
TypeId
When implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute.)

Examples

The following example shows how to export a context provider.
CopyC#
using System;
using System.Collections.Generic;
using Hypertable.Composition;

[ExportContextProvider("SampleContextProvider")]
public class SampleContextProvider : IContextProvider
{
    public Func<IDictionary<string, object>, IContext> Provider {
        get {
            return (properties) => new SampleContext(properties);
        }
    }
}

void foo() {
   // set the "Ht4n.Composition.ComposablePartCatalogs" property which expects
   // a ComposablePartCatalog or an IEnumerable<ComposablePartCatalog>
   var properties = new Dictionary<string, object>
      {
         { "Ht4n.Composition.ComposablePartCatalogs", new AssemblyCatalog(Assembly.GetExecutingAssembly()) }
      };
   using (var context = Context.Create("Provider=SampleContextProvider", properties)) {
      // use the context
   }
}

Inheritance Hierarchy

System..::..Object
  System..::..Attribute
    System.ComponentModel.Composition..::..ExportAttribute
      Hypertable.Composition..::..ExportContextProviderAttribute

See Also