Maps Ministry Documents
상속: BinaryFileComponent, IBinaryFile
예제 #1
0
        public static IBinaryFile GetAdapter(string fileName)
        {
            // create the adapter so we can instantiate it later
            IBinaryFile adapter = null;

            // declare the component class we're looking for
            var iBinaryFileType = typeof(IBinaryFile);

            // get the available binary file maps
            var binaryFileMaps = iBinaryFileType.Assembly.ExportedTypes.Where(p => iBinaryFileType.IsAssignableFrom(p) && !p.IsInterface);

            // pick the one that starts with the name of this .zip
            var selectedType = binaryFileMaps.FirstOrDefault(t => fileName.StartsWith(t.Name.RemoveWhitespace()));

            // assume Ministry Document (generic data type) by default
            if (selectedType != null)
            {
                adapter = (IBinaryFile)Activator.CreateInstance(selectedType);
            }
            else
            {
                adapter = new MinistryDocument();
            }

            return(adapter);
        }
예제 #2
0
        public static IBinaryFile GetAdapter(string fileName)
        {
            IBinaryFile adapter = null;

            var configFileTypes = ConfigurationManager.GetSection("binaryFileTypes") as NameValueCollection;

            // by default will assume a ministry document
            var iBinaryFileType = typeof(IBinaryFile);
            var mappedFileTypes = iBinaryFileType.Assembly.ExportedTypes
                                  .Where(p => iBinaryFileType.IsAssignableFrom(p) && !p.IsInterface);
            var selectedType = mappedFileTypes.FirstOrDefault(t => fileName.StartsWith(t.Name.RemoveWhitespace()));

            if (selectedType != null)
            {
                adapter = (IBinaryFile)Activator.CreateInstance(selectedType);
            }
            else
            {
                adapter = new MinistryDocument();
            }

            return(adapter);
        }
예제 #3
0
        public static IBinaryFile GetAdapter( string fileName )
        {
            // create the adapter so we can instantiate it later
            IBinaryFile adapter = null;

            // declare the component class we're looking for
            var iBinaryFileType = typeof( IBinaryFile );

            // get the available binary file maps
            var binaryFileMaps = iBinaryFileType.Assembly.ExportedTypes.Where( p => iBinaryFileType.IsAssignableFrom( p ) && !p.IsInterface );

            // pick the one that starts with the name of this .zip
            var selectedType = binaryFileMaps.FirstOrDefault( t => fileName.StartsWith( t.Name.RemoveWhitespace() ) );

            // assume Ministry Document (generic data type) by default
            if ( selectedType != null )
            {
                adapter = (IBinaryFile)Activator.CreateInstance( selectedType );
            }
            else
            {
                adapter = new MinistryDocument();
            }

            return adapter;
        }