Beispiel #1
0
        public static Plugin Create(string assemblyFile, string typeName)
        {
            if (!assemblyFile.Contains(".dll"))
                assemblyFile += ".dll";

            if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + assemblyFile))
                return null;

            Assembly asm = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + assemblyFile);
            Type type = asm.GetType(typeName);
            PluginMap map = new PluginMap();
            MethodInfo method = null; 
            foreach (string key in map.Keys)
            {
                if (map.ContainsKey(key))
                {
                    method = type.GetMethod(key);
                    map.Set(key, method);
                }    
            } 
            if (map.IsValid())
            {
                Plugin plug = new Plugin(asm.CreateInstance(typeName), map);
                plug.CreateInstance();
                return plug;
            }
            else
                return null;
        }
Beispiel #2
0
        public static Plugin Create(string assemblyFile, string typeName)
        {
            if (!assemblyFile.Contains(".dll"))
            {
                assemblyFile += ".dll";
            }

            if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + assemblyFile))
            {
                return(null);
            }

            Assembly   asm    = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + assemblyFile);
            Type       type   = asm.GetType(typeName);
            PluginMap  map    = new PluginMap();
            MethodInfo method = null;

            foreach (string key in map.Keys)
            {
                if (map.ContainsKey(key))
                {
                    method = type.GetMethod(key);
                    map.Set(key, method);
                }
            }
            if (map.IsValid())
            {
                Plugin plug = new Plugin(asm.CreateInstance(typeName), map);
                plug.CreateInstance();
                return(plug);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
 public Plugin(object instance, PluginMap map)
 {
     this.type     = instance.GetType();
     this.instance = instance;
     this.map      = map;
 }
Beispiel #4
0
 public Plugin(object instance, PluginMap map)
 {
     this.type = instance.GetType();
     this.instance = instance;
     this.map = map;
 }