Interface to be implemented when a custom
CompositionContext is used.
Syntax
Example
C# | Copy Code |
---|
// Sample ICompositionContextResolver used when using one or more custom contexts.
public class CompositionContextResolver : ICompositionContextResolver {
public static CompositionContext myMock = new CompositionContext("MyMock", true,
typeof(MockEntityServerSaveInterceptor), typeof(MockEntityServerQueryInterceptor));
public CompositionContext GetCompositionContext(string compositionContextName) {
if (compositionContextName == myMock.Name) {
return myMock;
} else {
return null;
}
}
}
// Sample class - note it is marked as not discoverable so that standard MEF
// composition will not find it.
[PartNotDiscoverable]
public class MockEntityServerQueryInterceptor : EntityServerQueryInterceptor {
protected override bool ExecuteQuery() {
throw new InvalidOperationException();
}
}
[PartNotDiscoverable]
public class MockEntityServerSaveInterceptor : EntityServerSaveInterceptor {
protected override bool ExecuteSave() {
throw new InvalidOperationException();
}
} |
Remarks
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