IdeaBlade.Core Assembly > IdeaBlade.Core.Composition Namespace > CompositionContext Class > WithGenerator Method : WithGenerator(Type) Method |
'Declaration
Public Overloads Function WithGenerator( _ ByVal type As Type _ ) As CompositionContext
'Usage
Dim instance As CompositionContext Dim type As Type Dim value As CompositionContext value = instance.WithGenerator(type)
public CompositionContext WithGenerator( Type type )
Exception | Description |
---|---|
System.ArgumentException | Thrown if the type does not have a composable base type or interface |
public class CompositionContextResolver : BaseCompositionContextResolver { // Creates a new context from the Default context, indicating that the // specified type should be used whenever an export // matching its interface/base class is requested. CompositionContext Mock = CompositionContext.Default .WithGenerator(typeof(MockEntityServerQueryInterceptor)) .WithName("Mock"); } [PartNotDiscoverable] public class MockEntityServerQueryInterceptor : EntityServerQueryInterceptor { protected override bool ExecuteQuery() { throw new InvalidOperationException(); } }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2