Esempio n. 1
0
 internal LifetimeContext(LifetimeContext parent, string[] sharingBoundaries)
 {
     _parent            = parent;
     _root              = parent._root;
     _sharingBoundaries = sharingBoundaries;
     _partRegistry      = parent._partRegistry;
 }
Esempio n. 2
0
 internal LifetimeContext(LifetimeContext parent, string[] sharingBoundaries)
 {
     _parent = parent;
     _root = parent._root;
     _sharingBoundaries = sharingBoundaries;
     _partRegistry = parent._partRegistry;
 }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        /// <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);
        }
Esempio n. 10
0
        /// <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);
            }
        }
Esempio n. 11
0
 internal LifetimeContext(ExportDescriptorRegistry partRegistry, string[] sharingBoundaries)
 {
     _root = this;
     _sharingBoundaries = sharingBoundaries;
     _partRegistry = partRegistry;
 }
Esempio n. 12
0
 internal LifetimeContext(ExportDescriptorRegistry partRegistry, string[] sharingBoundaries)
 {
     _root = this;
     _sharingBoundaries = sharingBoundaries;
     _partRegistry      = partRegistry;
 }
Esempio n. 13
0
        private CompositionHost(LifetimeContext rootLifetimeContext)
        {
            Requires.NotNull(rootLifetimeContext, "rootLifetimeContext");

            _rootLifetimeContext = rootLifetimeContext;
        }
		public CompositeActivatorParameters( LifetimeContext context, CompositionOperation operation )
		{
			Context = context;
			Operation = operation;
		}
Esempio n. 15
0
 /// <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 !!)