internal LifetimeContext(LifetimeContext parent, string[] sharingBoundaries) { _parent = parent; _root = parent._root; _sharingBoundaries = sharingBoundaries; _partRegistry = parent._partRegistry; }
private object Activate(LifetimeContext context, CompositionOperation operation) { Assumes.IsTrue(_exportDescriptor.IsValueCreated, "Activation in progress before all descriptors fully initialized."); Debug.WriteLine("[System.Composition] Activating via cycle-breaking proxy."); return(_exportDescriptor.Value.Activator(context, operation)); }
private object Activate(LifetimeContext context, CompositionOperation operation) { Assumes.IsTrue(_exportDescriptor.IsValueCreated, "Activation in progress before all descriptors fully initialized."); Debug.WriteLine("[System.Composition] Activating via cycle-breaking proxy."); return _exportDescriptor.Value.Activator(context, operation); }
private object Activate(LifetimeContext context, CompositionOperation operation) { if (!_exportDescriptor.IsValueCreated) { throw ThrowHelper.NotImplemented_MetadataCycles(); } Debug.WriteLine("[System.Composition] Activating via cycle-breaking proxy."); return(_exportDescriptor.Value.Activator(context, operation)); }
/// <summary> /// Execute a new composition operation starting within the specified lifetime /// context, for the specified activator. /// </summary> /// <param name="outermostLifetimeContext">Context in which to begin the operation (the operation can flow /// to the parents of the context if requried).</param> /// <param name="compositionRootActivator">Activator that will drive the operation.</param> /// <returns>The composed object graph.</returns> public static object Run(LifetimeContext outermostLifetimeContext, CompositeActivator compositionRootActivator) { Requires.NotNull(outermostLifetimeContext, nameof(outermostLifetimeContext)); Requires.NotNull(compositionRootActivator, nameof(compositionRootActivator)); using (var operation = new CompositionOperation()) { var result = compositionRootActivator(outermostLifetimeContext, operation); operation.Complete(); return result; } }
/// <summary> /// Execute a new composition operation starting within the specified lifetime /// context, for the specified activator. /// </summary> /// <param name="outermostLifetimeContext">Context in which to begin the operation (the operation can flow /// to the parents of the context if requried).</param> /// <param name="compositionRootActivator">Activator that will drive the operation.</param> /// <returns>The composed object graph.</returns> public static object Run(LifetimeContext outermostLifetimeContext, CompositeActivator compositionRootActivator) { Requires.ArgumentNotNull(outermostLifetimeContext, "outermostLifetimeContext"); Requires.ArgumentNotNull(compositionRootActivator, "compositionRootActivator"); using (var operation = new CompositionOperation()) { var result = compositionRootActivator(outermostLifetimeContext, operation); operation.Complete(); return(result); } }
private object Activate(LifetimeContext context, CompositionOperation operation) { if (!_exportDescriptor.IsValueCreated) { var ex = new NotImplementedException(SR.NotImplemented_MetadataCycles); Debug.WriteLine(SR.Diagnostic_ThrowingException, ex.ToString()); throw ex; } Debug.WriteLine("[System.Composition] Activating via cycle-breaking proxy."); return(_exportDescriptor.Value.Activator(context, operation)); }
/// <summary> /// Create the composition host. /// </summary> /// <returns>The container as an <see cref="CompositionHost"/>.</returns> public static CompositionHost CreateCompositionHost(IEnumerable<ExportDescriptorProvider> providers) { Requires.NotNull(providers, "providers"); var allProviders = new ExportDescriptorProvider[] { new LazyExportDescriptorProvider(), new ExportFactoryExportDescriptorProvider(), new ImportManyExportDescriptorProvider(), new LazyWithMetadataExportDescriptorProvider(), new CurrentScopeExportDescriptorProvider(), new ExportFactoryWithMetadataExportDescriptorProvider() } .Concat(providers) .ToArray(); var container = new LifetimeContext(new ExportDescriptorRegistry(allProviders), s_noBoundaries); return new CompositionHost(container); }
/// <summary> /// Execute a new composition operation starting within the specified lifetime /// context, for the specified activator. /// </summary> /// <param name="outermostLifetimeContext">Context in which to begin the operation (the operation can flow /// to the parents of the context if required).</param> /// <param name="compositionRootActivator">Activator that will drive the operation.</param> /// <returns>The composed object graph.</returns> public static object Run(LifetimeContext outermostLifetimeContext, CompositeActivator compositionRootActivator) { if (outermostLifetimeContext is null) { throw new ArgumentNullException(nameof(outermostLifetimeContext)); } if (compositionRootActivator is null) { throw new ArgumentNullException(nameof(compositionRootActivator)); } using (var operation = new CompositionOperation()) { var result = compositionRootActivator(outermostLifetimeContext, operation); operation.Complete(); return(result); } }
internal LifetimeContext(ExportDescriptorRegistry partRegistry, string[] sharingBoundaries) { _root = this; _sharingBoundaries = sharingBoundaries; _partRegistry = partRegistry; }
private CompositionHost(LifetimeContext rootLifetimeContext) { Requires.NotNull(rootLifetimeContext, "rootLifetimeContext"); _rootLifetimeContext = rootLifetimeContext; }
public CompositeActivatorParameters( LifetimeContext context, CompositionOperation operation ) { Context = context; Operation = operation; }
/// <summary> /// Execute a new composition operation starting within the specified lifetime /// context, for the specified activator. /// </summary> /// <param name="outermostLifetimeContext">Context in which to begin the operation (the operation can flow /// to the parents of the context if required).</param> /// <param name="compositionRootActivator">Activator that will drive the operation.</param> /// <returns>The composed object graph.</returns> public static object Run(LifetimeContext outermostLifetimeContext !!, CompositeActivator compositionRootActivator !!)