Exemplo n.º 1
0
 public void AddRange(DataCheckPluginCollection value)
 {
     for (int i = 0; i < value.Capacity; i++)
     {
         this.Add((IDataCheck)value.List[i]);
     }
 }
Exemplo n.º 2
0
        private GeoDataChecker()
        {
            //获取数据检查实现类
            DataCheckPluginHandle     dataCheckPluginHandle     = new DataCheckPluginHandle(Application.StartupPath + "\\..\\Plugins", "GeoDataChecker.dll");
            DataCheckPluginCollection dataCheckPluginCollection = dataCheckPluginHandle.GetPluginFromDLL();

            DicCheck = new Dictionary <string, IDataCheck>();
            foreach (IDataCheck plugin in dataCheckPluginCollection)
            {
                DicCheck.Add(plugin.ToString(), plugin);
            }
        }
Exemplo n.º 3
0
        public DataCheckPluginCollection GetPluginFromDLL()
        {
            //插件接口容器
            DataCheckPluginCollection PluginCol = new DataCheckPluginCollection();

            //检查插件文件夹是否存在
            if (!Directory.Exists(_pluginFolder))
            {
                Directory.CreateDirectory(_pluginFolder);
            }

            //获取DLL
            string[] dllFiles = Directory.GetFiles(_pluginFolder, _searchPattern);
            foreach (string file in dllFiles)
            {
                Assembly assembly = Assembly.LoadFrom(file);
                if (assembly != null)
                {
                    Type[] types = null;
                    try
                    {
                        types = assembly.GetTypes();
                    }
                    catch
                    {
                    }

                    if (types == null)
                    {
                        continue;
                    }
                    foreach (Type type in types)
                    {
                        Type[] interfaces = type.GetInterfaces();
                        foreach (Type ainterface in interfaces)
                        {
                            switch (ainterface.FullName)
                            {
                            case "GeoDataChecker.IDataCheckRealize":
                                GetPluginObject(PluginCol, type);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            return(PluginCol);
        }
Exemplo n.º 4
0
        private void GetPluginObject(DataCheckPluginCollection PluginCol, Type type)
        {
            IDataCheck plugin = null;

            try
            {
                plugin = Activator.CreateInstance(type) as IDataCheck;
            }
            catch
            {
            }
            finally
            {
                if (plugin != null)
                {
                    if (!PluginCol.Contains(plugin))
                    {
                        PluginCol.Add(plugin);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public DataCheckPluginCollection(DataCheckPluginCollection value)
 {
     this.AddRange(value);
 }
Exemplo n.º 6
0
 public DataCheckPluginCollectionEnumerator(DataCheckPluginCollection PluginCollection)
 {
     temp       = (IEnumerable)PluginCollection;
     enumerator = temp.GetEnumerator();
 }