コード例 #1
0
ファイル: Plugin.cs プロジェクト: WolfpawGroup/RTC3
 public Plugin(IChainChompCorruptor newInstance)
 {
     corruptor              = newInstance;
     settings.pluginName    = newInstance.Name;
     settings.pluginAuthor  = newInstance.Author;
     settings.pluginVersion = newInstance.Version;
 }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: WolfpawGroup/RTC3
 public Plugin(string path)
 {
     LoadSettings(path);
     corruptor = PluginManager.Current.CreateMatchingCorruptor(settings);
     if (settings != null)
     {
         settings.Restore(corruptor);
     }
     else
     {
         MessageBox.Show("Attempted to load a Corruptor that is not installed.", "Error", MessageBoxButtons.OK);
     }
 }
コード例 #3
0
ファイル: PluginSettings.cs プロジェクト: WolfpawGroup/RTC3
        public void Restore(IChainChompCorruptor corruptor)
        {
            Type t = corruptor.GetType();

            foreach (PropertyInfo prop in t.GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                if (Attribute.IsDefined(prop, typeof(SaveableSetting)))
                {
                    object value = data[prop.Name];

                    prop.SetValue(corruptor, Convert.ChangeType(value, prop.PropertyType));
                }
            }
        }
コード例 #4
0
ファイル: PluginSettings.cs プロジェクト: WolfpawGroup/RTC3
        public void Store(IChainChompCorruptor corruptor)
        {
            Type t = corruptor.GetType();

            data = new Dictionary <string, dynamic>();

            foreach (PropertyInfo prop in t.GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                if (Attribute.IsDefined(prop, typeof(SaveableSetting)))
                {
                    dynamic value = prop.GetValue(corruptor);
                    string  name  = prop.Name;

                    data.Add(name, value);
                }
            }
        }
コード例 #5
0
ファイル: PluginManager.cs プロジェクト: WolfpawGroup/RTC3
        //plugin loader
        private ICollection <IChainChompCorruptor> LoadPlugins(string path)
        {
            //aggregate files
            string[] dllFileNames = new string[0];
            if (Directory.Exists(path))
            {
                dllFileNames = Directory.GetFiles(path, "*.dll");
            }

            //load assemblies
            ICollection <Assembly> assemblies = new List <Assembly>(dllFileNames.Length);

            foreach (string dll in dllFileNames)
            {
                AssemblyName assN;
                try
                {
                    assN = AssemblyName.GetAssemblyName(dll);
                }
                catch (FileLoadException e)
                {
                    MessageBox.Show(e.Message);
                    continue;
                }

                Console.WriteLine(assN.FullName);
                Assembly ass;
                try
                {
                    ass = Assembly.Load(assN);
                }
                catch (FileLoadException e)
                {
                    MessageBox.Show(e.Message);
                    continue;
                }
                assemblies.Add(ass);
            }

            //search assemblies for corruptors
            Type corruptorType             = typeof(IChainChompCorruptor);
            ICollection <Type> pluginTypes = new List <Type>();

            foreach (Assembly assembly in assemblies)
            {
                if (assembly != null)
                {
                    Type[] types = assembly.GetTypes();
                    foreach (Type type in types)
                    {
                        if (type.IsInterface || type.IsAbstract)
                        {
                            continue;
                        }
                        else
                        {
                            if (type.GetInterface(corruptorType.FullName) != null)
                            {
                                pluginTypes.Add(type);
                            }
                        }
                    }
                }
            }

            //create instances
            ICollection <IChainChompCorruptor> plugins = new List <IChainChompCorruptor>(pluginTypes.Count);

            foreach (Type type in pluginTypes)
            {
                IChainChompCorruptor corruptor = (IChainChompCorruptor)Activator.CreateInstance(type);
                plugins.Add(corruptor);
            }

            return(plugins);
        }
コード例 #6
0
ファイル: PluginManager.cs プロジェクト: WolfpawGroup/RTC3
        public IChainChompCorruptor CreateMatchingCorruptor(PluginSettings settings)
        {
            IChainChompCorruptor x = FindMatchingPlugin(settings);

            return(x != null?CreateCorruptor(_plugins.IndexOf(x)) : null);
        }
コード例 #7
0
ファイル: ChainEditor.cs プロジェクト: WolfpawGroup/RTC3
        // Chain Expansion
        private void pluginDropDown_SelectedIndexChanged(object sender, EventArgs e)
        {
            IChainChompCorruptor c = PluginManager.Current.GetCorruptor((ComboBoxItem)pluginDropDown.SelectedItem);

            editorToolTip.SetToolTip(pluginDropDown, string.Format("{0} (Version {1} by {2})", c.Name, c.Version, c.Author));
        }
コード例 #8
0
ファイル: Plugin.cs プロジェクト: WolfpawGroup/RTC3
 public Plugin(IChainChompCorruptor newInstance, string path) : this(newInstance)
 {
     LoadSettings(path, true);
 }