DevForce Help Reference
ICompositionContextResolver Interface
Members  Example 


Interface to be implemented when a custom CompositionContext is used.
Syntax
'Declaration
 
<InterfaceExportAttribute(ContractName="", ContractType=IdeaBlade.Core.Composition.ICompositionContextResolver)>
Public Interface ICompositionContextResolver 
'Usage
 
Dim instance As ICompositionContextResolver
[InterfaceExport(ContractName="", ContractType=IdeaBlade.Core.Composition.ICompositionContextResolver)]
public interface ICompositionContextResolver 
Remarks
You can implement a custom ICompositionContextResolver to return your custom CompositionContext implementation(s).
Example
// 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();
   }
}
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

ICompositionContextResolver Members
IdeaBlade.Core.Composition Namespace
BaseCompositionContextResolver Class

Send Feedback