Ejemplo n.º 1
0
        public IntPtr LoadPlugin(string path)
        {
            if (!File.Exists(path) || !path.EndsWith(".dll"))
            {
                return(IntPtr.Zero);
            }

            path = VersionFile(path);
            if (path == null)
            {
                return(IntPtr.Zero);
            }

            Assembly assembly;

            try
            {
                assembly = Assembly.LoadFile(path);
            }
            catch (Exception)
            {
                return(IntPtr.Zero);
            }

            Type pluginType = null;

            foreach (var type in assembly.GetTypes())
            {
                if (!type.IsClass)
                {
                    continue;
                }

                if (type.BaseType == typeof(PluginApplication))
                {
                    pluginType = type;
                    break;
                }
            }

            if (pluginType == null)
            {
                return(IntPtr.Zero);
            }

            var plugin = Activator.CreateInstance(pluginType, _context) as PluginApplication;

            if (plugin is null)
            {
                return(IntPtr.Zero);
            }

            plugin.Load();
            _plugins.Add(plugin);

            return(PluginApplication.getCPtr(plugin).Handle);
        }
 // Called by COM
 public IBrokeredDvcChannelServiceInstance AcceptConnection(IBrokeredDvcChannelConnection client)
 {
     try
     {
         var thunk = new ChannelThunk(client);
         Parent.AcceptConnectionInternal(thunk);
         return(thunk);
     }
     catch (Exception ex)
     {
         PluginApplication.Log($"Exception accepting connection: {ex}");
         return(null);
     }
 }
Ejemplo n.º 3
0
 static void Main(string[] args)
 {
     PluginApplication.Run(args, new Dictionary <string, Action <IAsyncDvcChannel> > {
         { "TEST1", HandleTest2 }
     });
 }