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



Abstract ICompositionContextResolver that automatically registers any statically defined CompositionContexts found within the class.

Syntax

Visual Basic (Declaration) 
<PartNotDiscoverableAttribute()>
Public MustInherit Class BaseCompositionContextResolver 
   Implements ICompositionContextResolver 
Visual Basic (Usage)Copy Code
Dim instance As BaseCompositionContextResolver
C# 
[PartNotDiscoverableAttribute()]
public abstract class BaseCompositionContextResolver : ICompositionContextResolver  
C++/CLI 
[PartNotDiscoverableAttribute()]
public ref class BaseCompositionContextResolver abstract : public ICompositionContextResolver  

Example

C#Copy Code
// Sample BaseCompositionContextResolver sub-type providing static fields defining CompositionContexts.
public class CompositionContextResolver : BaseCompositionContextResolver {
 
  public static CompositionContext Mock = new CompositionContext("MyMock", true,
    typeof(MockEntityServerSaveInterceptor), typeof(MockEntityServerQueryInterceptor));
}
 
// 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

If you subclass the BaseCompositionContextResolver and provide static field definitions for your custom CompositionContexts, DevForce will automatically find and register these contexts as needed, and you will not need to implement the GetCompositionContext method. You can still use GetCompositionContext to dynamically construct a CompositionContext for the specified name, but there is no need to do so if all of your composition contexts can be defined statically.

Inheritance Hierarchy

System.Object
   IdeaBlade.Core.Composition.BaseCompositionContextResolver

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.