IdeaBlade DevForce 2010 Help Reference
WithGenerator(IEnumerable<Type>) Method
See Also  Example Send Feedback
IdeaBlade.Core Assembly > IdeaBlade.Core.Composition Namespace > CompositionContext Class > WithGenerator Method : WithGenerator(IEnumerable<Type>) Method



types
Creates a new CompositionContext from the current context with filtering for the types specified.

Syntax

Visual Basic (Declaration) 
Public Overloads Function WithGenerator( _
   ByVal types As IEnumerable(Of Type) _
) As CompositionContext
Visual Basic (Usage)Copy Code
Dim instance As CompositionContext
Dim types As IEnumerable(Of Type)
Dim value As CompositionContext
 
value = instance.WithGenerator(types)
C# 
public CompositionContext WithGenerator( 
   IEnumerable<Type> types
)
C++/CLI 
public:
CompositionContext^ WithGenerator( 
   IEnumerable<Type^>^ types
) 

Parameters

types

Exceptions

ExceptionDescription
System.ArgumentExceptionThrown if any type does not have a composable base type or interface

Example

C#Copy Code
public class CompositionContextResolver : BaseCompositionContextResolver {
  // Creates a new context from the Default context, indicating that the
  // specified types should be used whenever an export
  // matching its interface/base class is requested.
  CompositionContext Mock = CompositionContext.Default
    .WithGenerator(new[] {
     typeof(MockEntityServerQueryInterceptor),
     typeof(MockEntityServerSaveInterceptor)
    })
    .WithName("Mock");
}

[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 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.