Пример #1
0
        public static void LoadPlugin(string file)
        {
            Assembly assembly = Assembly.LoadFile(file);

            foreach (Type t in assembly.GetTypes())
            {
                if (typeof(IBackupFormat).IsAssignableFrom(t))
                {
                    IBackupFormat format = Activator.CreateInstance(t) as IBackupFormat;
                    BackupLoader.formats.Add(format);
                }
                if (typeof(IUpdater).IsAssignableFrom(t))
                {
                    IUpdater updater = Activator.CreateInstance(t) as IUpdater;
                    updater.SetPath(file);
                    DataHolder.AddUpdater(updater);
                }
                if (typeof(IPlugin).IsAssignableFrom(t))
                {
                    IPlugin plugin = Activator.CreateInstance(t) as IPlugin;
                    DataHolder.AddPlugin(plugin);
                }
            }
        }