/// <summary>
        /// Initializes a new instance of the <see cref="DiscoverPluginsInAssemblyDirectory"/> class.
        /// </summary>
        public DiscoverPluginsInAssemblyDirectory( )
        {
            var disk = new Disk( );

            string thisDirectory = disk.DirectoryOfExecutingAssembly ;

            var catalog = new DirectoryCatalog(thisDirectory);

            var container = new CompositionContainer(catalog);

            var batch = new CompositionBatch();
            batch.AddPart(this);

            container.Compose(batch);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads and validates the XML specified.  If no schema file exists, then validation is
        /// assumed to have succeeded.
        /// </summary>
        /// <param name="fileNameWithoutExtension">The file name without extension.</param>
        /// <returns>An <see cref="XDocument"/> that is validated against a 
        /// schema if a schema file exists.</returns>
        public static XDocument LoadAndValidate(string fileNameWithoutExtension )
        {
            var disk = new Disk( );

            string xmlPath = Path.Combine(
                disk.DirectoryOfExecutingAssembly,
                fileNameWithoutExtension + @".xml" ) ;

            string xsdPath = Path.Combine(
                disk.DirectoryOfExecutingAssembly,
                fileNameWithoutExtension + @".xsd" ) ;

            XDocument document = load( xmlPath ) ;

            validate( xsdPath, document ) ;

            return document ;
        }