Beispiel #1
0
 IKrotPlugin LoadPlugin(Assembly asm)
 {
     foreach (Type type in asm.GetTypes())
     {
         if (type.GetInterface("KrotAPI.IKrotPlugin") != null)
         {
             PluginType = type;
             dynamic     inst  = Activator.CreateInstance(type);
             IKrotPlugin inst2 = inst as IKrotPlugin;
             if (inst2 == null)
             {
                 return(inst);
             }
             Console.WriteLine("Есть привязка к стандартному API.");
             return(inst2);
         }
     }
     throw new Exception("Нет плагинов Крота в сборке.");
 }
Beispiel #2
0
        public PluginWrapper(string PluginPath, string PluginName)
        {
            try
            {
                Console.WriteLine("Loading plugin: " + PluginName);
                PluginAssembly = Assembly.LoadFrom(PluginPath);

                Plugin = LoadPlugin(PluginAssembly);

                Console.WriteLine("Plugin {0} has been loaded.", Plugin.GetName());
            }
            catch (Exception ex)
            {
                string innererr = "";
                if (ex.InnerException != null)
                {
                    innererr = String.Format("\nInner exception is {0} \\ ({1}), caused by {2}", ex.InnerException.GetType(), ex.InnerException.Message, ex.InnerException.Source);
                }
                Console.WriteLine("Can't load pugin: {0} {1}\n{2}", ex.GetType(), ex.Message, innererr);
                throw;
            }
            ProgressChangeHandler = PrgChng;             //undone: возможно, заглушка это плохо.
        }
Beispiel #3
0
 public PluginWrapper(IKrotPlugin KrotPlugin)
 {
     Console.WriteLine("Loading internal plugin: " + KrotPlugin.ToString());
     Plugin = KrotPlugin;
 }