Exemplo n.º 1
0
        /// <summary>
        /// Load the composite http service list.
        /// </summary>
        /// <param name="create">Create the composition collection or release.</param>
        public void Compose(bool create = true)
        {
            if (create)
            {
                // Read from the configuration file
                // all the directories that contain
                // any composite services.
                Nequeo.Composite.Configuration.Reader reader = new Nequeo.Composite.Configuration.Reader();
                string[] paths = reader.GetServicePaths();

                AggregateCatalog catalog = new AggregateCatalog();

                // For each directory found search for composite server assemplies
                // and add the reference of the assemblies into the handler collection
                foreach (string path in paths)
                {
                    catalog.Catalogs.Add(new DirectoryCatalog(path, "*HttpService.dll"));
                }

                // Add the collection catalog to the composite container
                _container = new CompositionContainer(catalog);
                _container.ComposeParts(this);
            }
            else
            {
                // Release the exported composite services.
                _container.ReleaseExports <IHttpServerContext, IContentMetadata>(HttpServerContext);
                _container.Dispose();

                // Release the handle.
                HttpServerContext = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Compose the MEF instance.
        /// </summary>
        internal virtual void Compose()
        {
            // Read from the configuration file
            // all the directories that contain
            // any composite services.
            Nequeo.Composite.Configuration.Reader reader = new Nequeo.Composite.Configuration.Reader();
            string[] paths = reader.GetServicePaths();

            AggregateCatalog catalog = new AggregateCatalog();

            // For each directory found search for composite server assemplies
            // and add the reference of the assemblies into the handler collection
            foreach (string path in paths)
            {
                catalog.Catalogs.Add(new DirectoryCatalog(path, "*MessageCompositionAssembly.dll"));
            }

            // Add the collection catalog to the composite container
            var container = new CompositionContainer(catalog);

            container.ComposeParts(this);
        }