Creates a new CompositionContext from the current context with filtering for the type specified.
Syntax
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