/// <summary>
        /// Registers all components in a MEF container attributed by "ComponentInterface" metadata tag.
        /// </summary>
        /// <param name="host"><see cref="ZyanComponentHost"/> or <see cref="ComponentCatalog"/> instance.</param>
        /// <param name="container">Root composition container used to instantiate components.</param>
        public static void RegisterComponents(this IComponentCatalog host, CompositionContainer container)
        {
            var rootCatalog      = container.Catalog;
            var nonSharedCatalog = new NonSharedPartsCatalog(rootCatalog);

            // register exported components
            foreach (var part in container.Catalog.Parts)
            {
                host.RegisterComponents(nonSharedCatalog, container, part);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Registers all components in a MEF catalog attributed by "ComponentInterface" metadata tag.
        /// </summary>
        public static void RegisterComponents(this IComponentCatalog host, ComposablePartCatalog rootCatalog)
        {
            var parentContainer  = new CompositionContainer(rootCatalog);
            var nonSharedCatalog = new NonSharedPartsCatalog(rootCatalog);

            // register exported components
            foreach (var part in rootCatalog.Parts)
            {
                host.RegisterComponents(nonSharedCatalog, parentContainer, part);
            }
        }
        /// <summary>
        /// Registers all components in a MEF catalog attributed by "ComponentInterface" metadata tag.
        /// </summary>
        /// <param name="host"><see cref="ZyanComponentHost"/> or <see cref="ComponentCatalog"/> instance.</param>
        /// <param name="rootCatalog">Component catalog to register components.</param>
        /// <param name="container">Optional root composition container used to instantiate components.</param>
        public static void RegisterComponents(this IComponentCatalog host, ComposablePartCatalog rootCatalog, CompositionContainer container = null)
        {
            var parentContainer = container ??
#if FX4
                                  new CompositionContainer(rootCatalog);
#else
                                  new CompositionContainer(rootCatalog, CompositionOptions.DisableSilentRejection);
#endif
            var nonSharedCatalog = new NonSharedPartsCatalog(rootCatalog);

            // register exported components
            foreach (var part in rootCatalog.Parts)
            {
                host.RegisterComponents(nonSharedCatalog, parentContainer, part);
            }
        }