DevForce Help Reference
WithGenerator(Type,Func<Object>) Method
Example 


A func which returns an instance of the type
Creates a new CompositionContext from the current context with filtering for the type specified.
Syntax
'Declaration
 
Public Overloads Function WithGenerator( _
   ByVal type As Type, _
   ByVal generatorFunc As Func(Of Object) _
) As CompositionContext
'Usage
 
Dim instance As CompositionContext
Dim type As Type
Dim generatorFunc As Func(Of Object)
Dim value As CompositionContext
 
value = instance.WithGenerator(type, generatorFunc)

Parameters

type
generatorFunc
A func which returns an instance of the type
Example
public class CompositionContextResolver : BaseCompositionContextResolver {
  // Creates a new context from the Default context, indicating that when
  // an EntityServerQueryInterceptor is needed it can be constructed
  // via the action provided.  
  CompositionContext Mock = CompositionContext.Default
    .WithGenerator(typeof(EntityServerQueryInterceptor), () => new MockEntityServerQueryInterceptor())
    .WithName("Mock");
}
 
[PartNotDiscoverable]
public class MockEntityServerQueryInterceptor : EntityServerQueryInterceptor {
  protected override bool ExecuteQuery() {
    throw new InvalidOperationException();
  }
}
Requirements

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

See Also

Reference

CompositionContext Class
CompositionContext Members
Overload List

Send Feedback