コード例 #1
0
        private static void InitializeMaps()
        {
            Dictionary <string, VirtualDiskFactory> typeMap = new Dictionary <string, VirtualDiskFactory>();

            foreach (var type in typeof(VirtualDisk).Assembly.GetTypes())
            {
                VirtualDiskFactoryAttribute attr = (VirtualDiskFactoryAttribute)Attribute.GetCustomAttribute(type, typeof(VirtualDiskFactoryAttribute), false);
                if (attr != null)
                {
                    VirtualDiskFactory factory = (VirtualDiskFactory)Activator.CreateInstance(type);
                    typeMap.Add(attr.Type, factory);
                }
            }

            s_typeMap = typeMap;
        }
コード例 #2
0
ファイル: VirtualDisk.cs プロジェクト: ibeae/ThinkAway.net
        private static void InitializeMaps()
        {
            Dictionary <string, VirtualDiskFactory> typeMap      = new Dictionary <string, VirtualDiskFactory>();
            Dictionary <string, VirtualDiskFactory> extensionMap = new Dictionary <string, VirtualDiskFactory>();

            foreach (var type in typeof(VirtualDisk).Assembly.GetTypes())
            {
                VirtualDiskFactoryAttribute attr = (VirtualDiskFactoryAttribute)Attribute.GetCustomAttribute(type, typeof(VirtualDiskFactoryAttribute), false);
                if (attr != null)
                {
                    VirtualDiskFactory factory = (VirtualDiskFactory)Activator.CreateInstance(type);
                    typeMap.Add(attr.Type, factory);
                    foreach (var extension in attr.FileExtensions)
                    {
                        extensionMap.Add(extension.ToUpperInvariant(), factory);
                    }
                }
            }

            s_typeMap      = typeMap;
            s_extensionMap = extensionMap;
        }