IdeaBlade DevForce 2010 Help Reference
ICompositionContextResolver Interface
Members  Example  See Also  Send Feedback
IdeaBlade.Core Assembly > IdeaBlade.Core.Composition Namespace : ICompositionContextResolver Interface



Interface to be implemented when a custom CompositionContext is used.

Syntax

Visual Basic (Declaration) 
<InheritedExportAttribute()>
Public Interface ICompositionContextResolver 
Visual Basic (Usage)Copy Code
Dim instance As ICompositionContextResolver
C# 
[InheritedExportAttribute()]
public interface ICompositionContextResolver 
C++/CLI 
[InheritedExportAttribute()]
public interface class ICompositionContextResolver 

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

You can implement a custom ICompositionContextResolver to return your custom CompositionContext implementation(s).

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.