IdeaBlade DevForce 2010 Help Reference
WithGenerator(Type,Func<Object>) Method
See Also  Example Send Feedback
IdeaBlade.Core Assembly > IdeaBlade.Core.Composition Namespace > CompositionContext Class > WithGenerator Method : WithGenerator(Type,Func<Object>) Method



type
generatorFunc
A func which returns an instance of the type
Creates a new CompositionContext from the current context with filtering for the type specified.

Syntax

Visual Basic (Declaration) 
Public Overloads Function WithGenerator( _
   ByVal type As Type, _
   ByVal generatorFunc As Func(Of Object) _
) As CompositionContext
Visual Basic (Usage)Copy Code
Dim instance As CompositionContext
Dim type As Type
Dim generatorFunc As Func(Of Object)
Dim value As CompositionContext
 
value = instance.WithGenerator(type, generatorFunc)
C# 
public CompositionContext WithGenerator( 
   Type type,
   Func<object> generatorFunc
)
C++/CLI 
public:
CompositionContext^ WithGenerator( 
   Type^ type,
   Func<Object^>^ generatorFunc
) 

Parameters

type
generatorFunc
A func which returns an instance of the type

Example

C#Copy Code
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 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2013 All Rights Reserved.