Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string PluginPath = "E:\\工程文件\\vs2015\\VS2015工程文件 C#\\TestOfPluginApi\\build\\bin\\";


            string[] files = Directory.GetFiles(PluginPath);
            foreach (string file in files)
            {
                string ext = file.Substring(file.LastIndexOf(".")).ToLower();
                if (ext != ".dll")
                {
                    continue;
                }

                try {
                    Assembly ass   = Assembly.LoadFrom(file);
                    Type[]   types = ass.GetTypes();
                    foreach (Type type in types)
                    {
                        if (IsValidPlugin(type))
                        {
                            IPluginBase customPlugin = (IPluginBase)ass.CreateInstance(type.FullName);
                        }
                    }
                } catch (Exception ex)
                {
                }
            }
        }
Beispiel #2
0
        public void DisposePlugin(IPluginBase plugin)
        {
            //Send event before delete
            if (this.PluginDeleted != null)
            {
                this.PluginDeleted(plugin);
            }

            var pluginContainer  = plugin as PluginContainer;
            var disposablePlugin = plugin as IDisposable;

            if (pluginContainer != null)
            {
                FPluginContainers.Remove(pluginContainer.PluginBase);
                pluginContainer.Dispose();
            }
            else if (FPluginContainers.ContainsKey(plugin))
            {
                FPluginContainers[plugin].Dispose();
                FPluginContainers.Remove(plugin);
            }
            else if (disposablePlugin != null)
            {
                disposablePlugin.Dispose();
            }
        }
Beispiel #3
0
 public void GetHDEPlugins(out IPluginBase nodeBrowser, out IPluginBase windowSwitcher, out IPluginBase kommunikator)
 {
     // HACK hack hack :/
     nodeBrowser = ((PluginContainer)FNodeBrowser).PluginBase;
     ((INodeBrowser)nodeBrowser).IsStandalone = false;
     ((INodeBrowser)nodeBrowser).DragDrop(false);
     windowSwitcher = ((PluginContainer)FWindowSwitcher).PluginBase;
     kommunikator   = ((PluginContainer)FKommunikator).PluginBase;
 }
        /// <summary>Instantiates a new plugin</summary>
        /// <param name="pluginEntryAssemblyFilePath"></param>
        /// <param name="sessionGuid"></param>
        /// <param name="mgrChannelName"></param>
        /// <param name="mgrProcess"></param>
        /// <param name="isDev"></param>
        /// <param name="cts"></param>
        protected PluginHostBase(
            string pluginEntryAssemblyFilePath,
            Guid sessionGuid,
            string mgrChannelName,
            Process mgrProcess,
            bool isDev,
            CancellationTokenSource cts)
        {
            this._cts = cts;

            // Connect to Plugin Manager
            var pluginMgr = RemotingServicesEx.ConnectToIpcServer <IPluginManager <ICore> >(mgrChannelName);

            if (pluginMgr == null)
            {
                Exit(PluginHostConst.ExitIpcConnectionError);
                return;
            }

            // Setup assembly resolution
            if (isDev)
            {
                AppDomain.CurrentDomain.AssemblyResolve += DevelopmentPluginAssemblyResolver;
            }

            // Load & create plugin
            _plugin = LoadAssembliesAndCreatePluginInstance(pluginEntryAssemblyFilePath);

            if (_plugin == null)
            {
                Exit(PluginHostConst.ExitNoPluginTypeFound);
                return;
            }

            // Connect plugin to Plugin Manager
            var core = pluginMgr.ConnectPlugin(
                _plugin.ChannelName,
                sessionGuid);

            if (core == null)
            {
                Exit(PluginHostConst.ExitCouldNotConnectPlugin);
                return;
            }

            // Inject properties
            InjectPropertyDependencies(_plugin, core, pluginMgr, sessionGuid, isDev);

            _plugin.OnInjected();

            // Start monitoring Plugin Manager process
            if (StartMonitoringPluginMgrProcess(mgrProcess) == false)
            {
                Exit(PluginHostConst.ExitParentExited);
            }
        }
Beispiel #5
0
        private static void LoadPluginBase(Type type)
        {
            IPluginBase plugin = (IPluginBase)Activator.CreateInstance(type);

            if (plugin == null)
            {
                throw new Exception("Cannot create the instance of plugin: " + type.Name);
            }
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Plugin Name: " + plugin.ModName + " Author: " + plugin.AuthorName);
            Console.ResetColor();
        }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Localization"/> class.
 /// </summary>
 /// <param name="plugin">Current plugin base.</param>
 public Localization(IPluginBase plugin)
 {
     this.plugin = plugin;
     this.SetLanguage(this.plugin.PluginInterface.UiLanguage);
     this.plugin.PluginInterface.OnLanguageChanged += this.OnLanguageChanged;
     this.plugin.PluginInterface.CommandManager.AddHandler(
         "/" + this.plugin.PluginName.ToLower() + "exloc",
         new CommandInfo(this.ExportLocalizable)
     {
         ShowInHelp = false,
     });
 }
Beispiel #7
0
        /// <summary>
        /// Drupal
        ///

        /// </summary>
        public static string GetLdapGUID(string dir)
        {
            string LdapGuid = null;


            if (!Directory.Exists(dir))
            {
                //m_logger.WarnFormat("Skipping invalid plugin directory: {0}", dir);
                return(null);
            }

            //m_logger.DebugFormat("Loading plugins from {0}", dir);

            //Drupal Path Hardcoded
            string file = dir + "\\Foxpass.Plugin.LDAP.dll";

            //foreach (string file in files)
            //{

            try
            {
                // Load the assembly up
                Assembly assembly = Assembly.LoadFile(file);

                foreach (Type type in assembly.GetTypes())
                {
                    // Make sure its a public class
                    if (!type.IsClass || type.IsNotPublic)
                    {
                        continue;
                    }

                    Type[] interfaces = type.GetInterfaces();
                    if (interfaces.Contains(typeof(IPluginBase)))
                    {
                        // TBD: We could do inverted control here.. logger, settings, etc?
                        //  We could also consider loading plugins in their own app domain,
                        //  making them unloadable...
                        object      pluginObject = Activator.CreateInstance(type);
                        IPluginBase pluginBase   = pluginObject as IPluginBase;
                        LdapGuid = pluginBase.Uuid.ToString();
                        //m_logger.DebugFormat("Created plugin object type: {0} from plugin: {1} uuid: {2}", type.ToString(), file, pluginBase.Uuid);
                    }
                }
            }
            catch (Exception ex)
            {
                //m_logger.ErrorFormat("Error loading {0}: {1}", file, ex);
            }

            return(LdapGuid);
        }
Beispiel #8
0
 static PluginInstanceManager()
 {
     Logger.Info("开始加载插件");
     try
     {
         var pluginInfo = GetPluginInfo();
         pluginInfo.ValidateFiles();
         Logger.Debug($"当前插件名称为{pluginInfo.Name}");
         var appDomainSetup = new AppDomainSetup
         {
             DisallowBindingRedirects = false,
             ApplicationBase          = pluginInfo.PluginEntyPointDirectory
         };
         if (File.Exists(pluginInfo.PluginEntryPointConfigFullFilename))
         {
             appDomainSetup.ConfigurationFile = pluginInfo.PluginEntryPointConfigFullFilename;
         }
         Logger.Debug($"创建AppDomain进行加载插件:{pluginInfo.Name}");
         var domain = AppDomain.CreateDomain(pluginInfo.Name, AppDomain.CurrentDomain.Evidence,
                                             appDomainSetup);
         domain.Load(new AssemblyName
         {
             CodeBase = pluginInfo.PluginEntryPointDllFullFilename,
         });
         Logger.Debug("开始创建透明代理");
         var objectHandle = domain.CreateInstanceFrom("Newbe.CQP.Framework.PluginLoader.dll",
                                                      typeof(CrossAppDomainPluginLoader).FullName);
         var loader = (CrossAppDomainPluginLoader)objectHandle.Unwrap();
         Logger.Debug(
             $"透明代理创建完毕,类型为{loader.GetType().FullName},将开始调用{nameof(CrossAppDomainPluginLoader.LoadPlugin)}方法");
         if (!loader.LoadPlugin(pluginInfo.PluginEntryPointDllFullFilename))
         {
             throw new PluginLoadException(pluginInfo.Name, loader.Message);
         }
         Instances.Add(pluginInfo.Name, loader);
         IPluginBase plugin = loader;
         Logger.Debug($"插件加载完毕:{pluginInfo.Name},AppId:{plugin.AppId},ApiVersion:{plugin.ApiVersion}");
     }
     catch (Exception e)
     {
         Logger.ErrorException(e.Message, e);
         var inner = e.InnerException;
         while (inner != null)
         {
             Logger.ErrorException(e.Message, e);
             inner = inner.InnerException;
         }
         throw;
     }
 }
Beispiel #9
0
        /// <summary>
        /// プラグイン情報設定
        /// </summary>
        private void SetPluginInfo(IPluginBase plugin)
        {
            PluginName.Value  = plugin.PluginName;
            Author.Value      = plugin.Author;
            Description.Value = plugin.Description;
            Version.Value     = plugin.Version;

            if (plugin is IPluginSender sender)
            {
                Visibility.Value = true;
                SiteName.Value   = sender.SiteName;
            }
            else
            {
                Visibility.Value = false;
            }
        }
Beispiel #10
0
        private static void LoadPluginsFromDir(string dir)
        {
            if (!Directory.Exists(dir))
            {
                m_logger.WarnFormat("Skipping invalid plugin directory: {0}", dir);
                return;
            }

            m_logger.DebugFormat("Loading plugins from {0}", dir);

            string[] files = Directory.GetFiles(dir, "pGina.Plugin.*.dll");
            foreach (string file in files)
            {
                try
                {
                    // Load the assembly up
                    Assembly assembly = Assembly.LoadFile(file);

                    foreach (Type type in assembly.GetTypes())
                    {
                        // Make sure its a public class
                        if (!type.IsClass || type.IsNotPublic)
                        {
                            continue;
                        }

                        Type[] interfaces = type.GetInterfaces();
                        if (interfaces.Contains(typeof(IPluginBase)))
                        {
                            // TBD: We could do inverted control here.. logger, settings, etc?
                            //  We could also consider loading plugins in their own app domain,
                            //  making them unloadable...
                            object      pluginObject = Activator.CreateInstance(type);
                            IPluginBase pluginBase   = pluginObject as IPluginBase;
                            m_logger.DebugFormat("Created plugin object type: {0} from plugin: {1} uuid: {2}", type.ToString(), file, pluginBase.Uuid);
                            m_plugins.Add(pluginObject as IPluginBase);
                        }
                    }
                }
                catch (Exception ex)
                {
                    m_logger.ErrorFormat("Error loading {0}: {1}", file, ex);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// The inject property dependencies.
        /// </summary>
        /// <param name="plugin">
        /// The plugin.
        /// </param>
        /// <param name="coreInst">
        /// The core inst.
        /// </param>
        /// <param name="pluginMgr">
        /// The plugin mgr.
        /// </param>
        /// <param name="sessionGuid">
        /// The session guid.
        /// </param>
        /// <param name="isDevelopment">
        /// The is development.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        private bool InjectPropertyDependencies(IPluginBase plugin,
                                                ICore coreInst,
                                                IPluginManager <ICore> pluginMgr,
                                                Guid sessionGuid,
                                                bool isDevelopment)
        {
            bool coreSet = false;
            bool mgrSet  = false;
            bool guidSet = false;
            var  type    = plugin.GetType();

            while (type != null && type != typeof(IPluginBase))
            {
                var props = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                foreach (var prop in props)
                {
                    if (CoreInterfaceTypes.Contains(prop.PropertyType) && prop.CanWrite)
                    {
                        prop.SetValue(plugin, coreInst /*Convert.ChangeType(coreInst, prop.PropertyType)*/);
                        coreSet = true;
                    }
                    else if (PluginMgrInterfaceTypes.Contains(prop.PropertyType) && prop.CanWrite)
                    {
                        prop.SetValue(plugin, pluginMgr /*Convert.ChangeType(pluginMgr, prop.PropertyType)*/);
                        mgrSet = true;
                    }
                    else if (prop.PropertyType == typeof(Guid) && prop.CanWrite)
                    {
                        prop.SetValue(plugin, sessionGuid);
                        guidSet = true;
                    }
                    else if (prop.PropertyType == typeof(bool) && prop.Name is "IsDevelopmentPlugin" && prop.CanWrite)
                    {
                        prop.SetValue(plugin, isDevelopment);
                    }
                }

                type = type.BaseType;
            }

            return(coreSet && mgrSet && guidSet);
        }
Beispiel #12
0
 public bool LoadPlugin(string pluginEntryPointDllFullFilename)
 {
     Debug($"当前AppDomain:{AppDomain.CurrentDomain.FriendlyName},开始加载插件程序集:{pluginEntryPointDllFullFilename}");
     try
     {
         Assembly.Load(new AssemblyName
         {
             CodeBase = pluginEntryPointDllFullFilename,
         });
         foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
         {
             Debug($"当前已加载程序集:{assembly.FullName}");
         }
         Debug($"程序集加载完毕,开始构建Container");
         var superBuilder = new ContainerBuilder();
         superBuilder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()).AsImplementedInterfaces()
             .AsSelf();
         var superContainer = superBuilder.Build();
         var subBuilderRegisters = superContainer.Resolve<IAutofacContainerBuilder[]>().ToArray();
         var builder = new ContainerBuilder();
         builder.Register(x => new CoolQApi()).AsImplementedInterfaces().SingleInstance();
         builder.RegisterAssemblyTypes(AppDomain.CurrentDomain.GetAssemblies()).AsImplementedInterfaces()
             .AsSelf();
         foreach (var autofacContainerBuilder in subBuilderRegisters)
         {
             autofacContainerBuilder.Register(builder);
         }
         var container = builder.Build();
         Debug($"Container构建完毕,尝试获取{nameof(IPluginBase)}实现类");
         var impls = container.Resolve<IEnumerable<IPluginBase>>().ToArray();
         Debug($"实现类一共{impls.Length}个");
         _pluginBase = impls.First(x => !(x is CrossAppDomainPluginLoader));
         Debug($"获取到了{_pluginBase.GetType().Name}作为{nameof(IPluginBase)}的实现类,插件加载完毕");
         return true;
     }
     catch (Exception ex)
     {
         Message = ex.Message;
         return false;
     }
 }
Beispiel #13
0
        public void DisposePlugin(IPluginBase plugin)
        {
            //Send event before delete
            PluginDeleted?.Invoke(plugin);

            var disposablePlugin = plugin as IDisposable;

            if (plugin is PluginContainer pluginContainer)
            {
                PluginContainers.Remove(pluginContainer.PluginBase);
                pluginContainer.Dispose();
            }
            else if (PluginContainers.ContainsKey(plugin))
            {
                PluginContainers[plugin].Dispose();
                PluginContainers.Remove(plugin);
            }
            else
            {
                disposablePlugin?.Dispose();
            }
        }
Beispiel #14
0
        public void Initialize(IVVVVHost vvvvHost, INodeBrowserHost nodeBrowserHost, IWindowSwitcherHost windowSwitcherHost, IKommunikatorHost kommunikatorHost)
        {
            //set blackbox mode?
            this.IsBlackBoxMode = vvvvHost.IsBlackBoxMode;

            // Set VVVV45 to this running vvvv.exe
            Environment.SetEnvironmentVariable(ENV_VVVV, Path.GetFullPath(Shell.CallerPath.ConcatPath("..").ConcatPath("..")));

            FVVVVHost       = vvvvHost;
            NodeInfoFactory = new ProxyNodeInfoFactory(vvvvHost.NodeInfoFactory);

            FVVVVHost.AddMouseClickListener(this);
            FVVVVHost.AddNodeSelectionListener(this);
            FVVVVHost.AddWindowListener(this);
            FVVVVHost.AddWindowSelectionListener(this);
            FVVVVHost.AddComponentModeListener(this);

            NodeInfoFactory.NodeInfoUpdated += factory_NodeInfoUpdated;

            // Route log messages to vvvv
            Logger.AddLogger(new VVVVLogger(FVVVVHost));

            DeviceService = new DeviceService(vvvvHost.DeviceService);
            MainLoop      = new MainLoop(vvvvHost.MainLoop);

            ExposedNodeService = new ExposedNodeService(vvvvHost.ExposedNodeService, NodeInfoFactory);

            NodeBrowserHost    = new ProxyNodeBrowserHost(nodeBrowserHost, NodeInfoFactory);
            WindowSwitcherHost = windowSwitcherHost;
            KommunikatorHost   = kommunikatorHost;

            //do not add the entire directory for faster startup
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(HDEHost).Assembly.Location));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodeCollection).Assembly.Location));
            //allow plugin writers to add their own factories (deprecated, see below)
            var factoriesPath = ExePath.ConcatPath(@"lib\factories");

            if (Directory.Exists(factoriesPath))
            {
                catalog.Catalogs.Add(new DirectoryCatalog(factoriesPath));
            }

            //search for packs, add factories dir to this catalog, add core dir to assembly search path,
            //add nodes to nodes search path
            var packsDirInfo = new DirectoryInfo(Path.Combine(ExePath, "packs"));

            if (packsDirInfo.Exists)
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve;
                foreach (var packDirInfo in packsDirInfo.GetDirectories())
                {
                    var packDir     = packDirInfo.FullName;
                    var coreDirInfo = new DirectoryInfo(Path.Combine(packDir, "core"));
                    if (coreDirInfo.Exists)
                    {
                        FAssemblySearchPaths.Add(coreDirInfo.FullName);
                        var platformDir = IntPtr.Size == 4 ? "x86" : "x64";
                        var platformDependentCorDirInfo = new DirectoryInfo(Path.Combine(coreDirInfo.FullName, platformDir));
                        if (platformDependentCorDirInfo.Exists)
                        {
                            FAssemblySearchPaths.Add(platformDependentCorDirInfo.FullName);
                        }
                    }
                    var factoriesDirInfo = new DirectoryInfo(Path.Combine(packDir, "factories"));
                    if (factoriesDirInfo.Exists)
                    {
                        catalog.Catalogs.Add(new DirectoryCatalog(factoriesDirInfo.FullName));
                    }
                    // We look for nodes later
                }
            }

            Container = new CompositionContainer(catalog);
            Container.ComposeParts(this);

            //NodeCollection.AddJob(Shell.CallerPath.Remove(Shell.CallerPath.LastIndexOf(@"bin\managed")));
            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\VVVV.Nodes.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\Kommunikator.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeBrowser.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeCollector.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\WindowSwitcher.dll"));

            //Get node infos from core plugins here to avoid looping all node infos
            var windowSwitcherNodeInfo = GetNodeInfo(WINDOW_SWITCHER);
            var kommunikatorNodeInfo   = GetNodeInfo(KOMMUNIKATOR);
            var nodeBrowserNodeInfo    = GetNodeInfo(NODE_BROWSER);

            foreach (var factory in AddonFactories)
            {
                if (factory is PatchFactory)
                {
                    NodeCollection.Add(string.Empty, ExePath.ConcatPath(@"lib\nodes\native\"), factory, true, false);
                }
            }

            //now instantiate a NodeBrowser, a Kommunikator and a WindowSwitcher
            FWindowSwitcher = PluginFactory.CreatePlugin(windowSwitcherNodeInfo, null);
            FKommunikator   = PluginFactory.CreatePlugin(kommunikatorNodeInfo, null);
            FNodeBrowser    = PluginFactory.CreatePlugin(nodeBrowserNodeInfo, null);

            this.IsBoygroupClient = FVVVVHost.IsBoygroupClient;
            if (IsBoygroupClient)
            {
                this.BoygroupServerIP = FVVVVHost.BoygroupServerIP;
            }


            //start time server of client
            FNetTimeSync = IsBoygroupClient ? new UDPTimeClient(BoygroupServerIP, 3334) : new UDPTimeServer(3334);
            FNetTimeSync.Start();

            //now that all basics are set up, see if there are any node search paths to add
            //from the installed packs
            if (packsDirInfo.Exists)
            {
                foreach (var packDirInfo in packsDirInfo.GetDirectories())
                {
                    var packDir      = packDirInfo.FullName;
                    var nodesDirInfo = new DirectoryInfo(Path.Combine(packDir, "nodes"));
                    if (nodesDirInfo.Exists)
                    {
                        NodeCollection.AddJob(nodesDirInfo.FullName, true);
                    }
                }
            }
        }
Beispiel #15
0
 public bool Equals(IPluginBase other)
 {
     return other.ID == ID;
 }
Beispiel #16
0
        public IPluginBase CreatePlugin(INodeInfo nodeInfo, IPluginHost2 pluginHost)
        {
            IPluginBase plugin = null;

            string assemblyLocation = string.Empty;
            var    isUpToDate       = GetAssemblyLocation(nodeInfo, out assemblyLocation);

            // HACK: pluginHost is null in case of WindowSwitcher/NodeBrowser/etc. Fix this.
            if (pluginHost != null)
            {
                // Mark the node if old assembly was loaded and log warning.
                if (!isUpToDate)
                {
                    pluginHost.Status |= StatusCode.HasInvalidData;
                    FLogger.Log(LogType.Warning, string.Format("Plugin of node '{0}' (ID: {1}) is out of date and couldn't be recompiled. Check its source code for errors.", nodeInfo.Username, pluginHost.GetID()));
                }
                else
                {
                    pluginHost.Status &= ~StatusCode.HasInvalidData;
                }
            }

            var assembly = Assembly.LoadFrom(assemblyLocation);

            //Check if need to start anything before rest is loaded
            FStartableRegistry.ProcessAssembly(assembly);

            var type = assembly.GetType(nodeInfo.Arguments);

            // type can be null if assembly is corrupt or doesn't contain cached node info anymore
            if (type != null)
            {
                var attribute = GetPluginInfoAttributeData(type);
                if (attribute != null)
                {
                    var pluginContainer = new PluginContainer(
                        pluginHost as IInternalPluginHost,
                        FIORegistry,
                        FParentContainer,
                        FNodeInfoFactory,
                        this,
                        type,
                        nodeInfo);

                    // We intercept the plugin to manage IOHandlers.
                    plugin = pluginContainer;
                    FPluginContainers[pluginContainer.PluginBase] = pluginContainer;

                    // HACK: FPluginHost is null in case of WindowSwitcher and friends
                    if (pluginHost != null)
                    {
                        AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, pluginContainer.PluginBase);
                    }

                    // Send event, clients are not interested in wrapping plugin, so send original here.
                    if (this.PluginCreated != null)
                    {
                        this.PluginCreated(pluginContainer.PluginBase, pluginHost);
                    }
                }
                else
                {
                    var v1Plugin = (IPlugin)assembly.CreateInstance(nodeInfo.Arguments);

                    v1Plugin.SetPluginHost(pluginHost);

                    plugin = v1Plugin;

                    // HACK: FPluginHost is null in case of WindowSwitcher and friends
                    if (pluginHost != null)
                    {
                        AssignOptionalPluginInterfaces(pluginHost as IInternalPluginHost, plugin);
                    }

                    // Send event
                    if (this.PluginCreated != null)
                    {
                        this.PluginCreated(plugin, pluginHost);
                    }
                }
            }
            else
            {
                pluginHost.Status |= StatusCode.HasInvalidData;
                FLogger.Log(LogType.Warning, string.Format("Type '{0}' not found in assembly '{1}'. Failed to create plugin node {2} (ID: {3}).", nodeInfo.Arguments, assembly.FullName, nodeInfo.Username, pluginHost.GetID()));
            }

            return(plugin);
        }
Beispiel #17
0
        public void Initialize(IVVVVHost vvvvHost, INodeBrowserHost nodeBrowserHost, IWindowSwitcherHost windowSwitcherHost, IKommunikatorHost kommunikatorHost)
        {
            // Used for Windows Forms message loop
            FIsRunning = true;

            //set blackbox mode?
            this.IsBlackBoxMode = vvvvHost.IsBlackBoxMode;

            // Set VVVV45 to this running vvvv.exe
            Environment.SetEnvironmentVariable(ENV_VVVV, Path.GetFullPath(Shell.CallerPath.ConcatPath("..").ConcatPath("..")));

            FVVVVHost       = vvvvHost;
            NodeInfoFactory = new ProxyNodeInfoFactory(vvvvHost.NodeInfoFactory);

            FVVVVHost.AddMouseClickListener(this);
            FVVVVHost.AddNodeSelectionListener(this);
            FVVVVHost.AddWindowListener(this);
            FVVVVHost.AddWindowSelectionListener(this);
            FVVVVHost.AddComponentModeListener(this);
            FVVVVHost.AddEnumListener(this);

            NodeInfoFactory.NodeInfoUpdated += factory_NodeInfoUpdated;

            // Route log messages to vvvv
            Logger.AddLogger(new VVVVLogger(FVVVVHost));

            DeviceService = new DeviceService(vvvvHost.DeviceService);
            MainLoop      = new MainLoop(vvvvHost.MainLoop);

            ExposedNodeService = new ExposedNodeService(vvvvHost.ExposedNodeService, NodeInfoFactory);

            NodeBrowserHost    = new ProxyNodeBrowserHost(nodeBrowserHost, NodeInfoFactory);
            WindowSwitcherHost = windowSwitcherHost;
            KommunikatorHost   = kommunikatorHost;

            //do not add the entire directory for faster startup
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(HDEHost).Assembly.Location));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodeCollection).Assembly.Location));
            //allow plugin writers to add their own factories (deprecated, see below)
            var factoriesPath = ExePath.ConcatPath(@"lib\factories");

            if (Directory.Exists(factoriesPath))
            {
                catalog.Catalogs.Add(new DirectoryCatalog(factoriesPath));
            }

            //register custom assembly resolvers which look also in the PACK_NAME/core and PACK_NAME/core/[x86|x64] folders
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomain_ReflectionOnlyAssemblyResolve;

            //search for packs, add factories dir to this catalog, add core dir to assembly search path,
            //add nodes to nodes search path
            var packsPath = Path.Combine(ExePath, "packs");

            if (Directory.Exists(packsPath))
            {
                LoadFactoriesFromLegacyPackages(packsPath, catalog);
            }
            //new package loading system
            LoadFactoriesFromPackages(catalog);

            Container = new CompositionContainer(catalog);
            Container.ComposeParts(this);

            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\VVVV.Nodes.dll"));

            //Get node infos from core plugins here to avoid looping all node infos
            var windowSwitcherNodeInfo = GetNodeInfo(WINDOW_SWITCHER);
            var kommunikatorNodeInfo   = GetNodeInfo(KOMMUNIKATOR);
            var nodeBrowserNodeInfo    = GetNodeInfo(NODE_BROWSER);

            foreach (var factory in AddonFactories)
            {
                if (factory is PatchFactory)
                {
                    NodeCollection.Add(string.Empty, ExePath.ConcatPath(@"lib\nodes\native\"), factory, true, false);
                }
            }

            //now instantiate a NodeBrowser, a Kommunikator and a WindowSwitcher
            FWindowSwitcher = PluginFactory.CreatePlugin(windowSwitcherNodeInfo, null);
            FKommunikator   = PluginFactory.CreatePlugin(kommunikatorNodeInfo, null);
            FNodeBrowser    = PluginFactory.CreatePlugin(nodeBrowserNodeInfo, null);

            this.IsBoygroupClient = FVVVVHost.IsBoygroupClient;
            if (IsBoygroupClient)
            {
                this.BoygroupServerIP = FVVVVHost.BoygroupServerIP;
            }

            var clockport = 3334;

            try
            {
                if (Environment.CommandLine.Contains("/clockport"))
                {
                    var env = Environment.GetCommandLineArgs();
                    var idx = Array.IndexOf(env, "/clockport") + 1;
                    clockport = int.Parse(env[idx]);
                }
            }
            catch (Exception)
            {
                throw new Exception("Could not parse clockport, make sure you have the right syntax, e.g. '/clockport 3344' ");
            }

            //start time server of client
            FNetTimeSync = IsBoygroupClient ? new UDPTimeClient(BoygroupServerIP, clockport) : new UDPTimeServer(clockport);
            FNetTimeSync.Start();

            //now that all basics are set up, see if there are any node search paths to add
            //from the installed packs
            if (Directory.Exists(packsPath))
            {
                LoadNodesFromLegacyPackages(packsPath);
            }
            LoadNodesFromPackages();
        }
Beispiel #18
0
        /// <summary>
        /// If the class implements the ExportJarsPlugin (or inherited from) attribute, this function will extract the name of the plugin given in the Attribute.
        /// </summary>
        /// <returns></returns>
        public static string GetPluginTextFromAttributeValue(this IPluginBase plugin)
        {
            IPluginMetadata attribute = plugin.GetType().GetCustomAttributes <ExportPluginAttribute>(false).FirstOrDefault();

            return((attribute != null) ? attribute.PluginText : plugin.GetType().Name);
        }
Beispiel #19
0
 /// <summary>
 /// Remove all the whitespace characters so the PluginText property so it can be used as a name on a control or key in a dictionary.
 /// </summary>
 /// <param name="plugin"></param>
 /// <returns></returns>
 public static string GetPluginTextAsNameValue(this IPluginBase plugin)
 {
     return(plugin.PluginText.Replace(" ", ""));
 }
Beispiel #20
0
        public static bool IsEnabledFor <T>(IPluginBase plugin) where T : IPluginBase
        {
            int pluginMask = Settings.Get.GetSetting(plugin.Uuid.ToString());

            return(IsEnabledFor <T>(pluginMask));
        }
Beispiel #21
0
 public ExplodeColumn(IPluginBase handler)
 {
     this.handler = handler;
     Text         = handler.FriendlyName;
 }
Beispiel #22
0
 public bool Equals(IPluginBase other)
 {
     return(other.ID == ID);
 }
Beispiel #23
0
        public void Initialize(IVVVVHost vvvvHost, INodeBrowserHost nodeBrowserHost, IWindowSwitcherHost windowSwitcherHost, IKommunikatorHost kommunikatorHost)
        {
            // Set VVVV45 to this running vvvv.exe
            Environment.SetEnvironmentVariable(ENV_VVVV, Path.GetFullPath(Shell.CallerPath.ConcatPath("..").ConcatPath("..")));

            FVVVVHost       = vvvvHost;
            NodeInfoFactory = new ProxyNodeInfoFactory(vvvvHost.NodeInfoFactory);

            FVVVVHost.AddMouseClickListener(this);
            FVVVVHost.AddNodeSelectionListener(this);
            FVVVVHost.AddWindowListener(this);
            FVVVVHost.AddWindowSelectionListener(this);

            NodeInfoFactory.NodeInfoUpdated += factory_NodeInfoUpdated;

            // Route log messages to vvvv
            Logger.AddLogger(new VVVVLogger(FVVVVHost));

            DeviceService = new DeviceService(vvvvHost.DeviceService);
            MainLoop      = new MainLoop(vvvvHost.MainLoop);

            ExposedNodeService = new ExposedNodeService(vvvvHost.ExposedNodeService, NodeInfoFactory);

            NodeBrowserHost    = new ProxyNodeBrowserHost(nodeBrowserHost, NodeInfoFactory);
            WindowSwitcherHost = windowSwitcherHost;
            KommunikatorHost   = kommunikatorHost;

            //do not add the entire directory for faster startup
            var catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new AssemblyCatalog(typeof(HDEHost).Assembly.Location));
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(NodeCollection).Assembly.Location));
            //allow plugin writers to add their own factories
            var factoriesPath = ExePath.ConcatPath(@"lib\factories");

            if (Directory.Exists(factoriesPath))
            {
                catalog.Catalogs.Add(new DirectoryCatalog(factoriesPath));
            }
            Container = new CompositionContainer(catalog);
            Container.ComposeParts(this);

            //NodeCollection.AddJob(Shell.CallerPath.Remove(Shell.CallerPath.LastIndexOf(@"bin\managed")));
            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\VVVV.Nodes.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\Kommunikator.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeBrowser.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\NodeCollector.dll"));
//            PluginFactory.AddFile(ExePath.ConcatPath(@"lib\nodes\plugins\WindowSwitcher.dll"));

            //Get node infos from core plugins here to avoid looping all node infos
            var windowSwitcherNodeInfo = GetNodeInfo(WINDOW_SWITCHER);
            var kommunikatorNodeInfo   = GetNodeInfo(KOMMUNIKATOR);
            var nodeBrowserNodeInfo    = GetNodeInfo(NODE_BROWSER);

            foreach (var factory in AddonFactories)
            {
                if (factory is PatchFactory)
                {
                    NodeCollection.Add(string.Empty, ExePath.ConcatPath(@"lib\nodes\native\"), factory, true, false);
                }
            }

            //now instantiate a NodeBrowser, a Kommunikator and a WindowSwitcher
            FWindowSwitcher = PluginFactory.CreatePlugin(windowSwitcherNodeInfo, null);
            FKommunikator   = PluginFactory.CreatePlugin(kommunikatorNodeInfo, null);
            FNodeBrowser    = PluginFactory.CreatePlugin(nodeBrowserNodeInfo, null);

            this.IsBoygroupClient = FVVVVHost.IsBoygroupClient;
            if (IsBoygroupClient)
            {
                this.BoygroupServerIP = FVVVVHost.BoygroupServerIP;
            }


            //start time server of client
            FNetTimeSync = IsBoygroupClient ? new UDPTimeClient(BoygroupServerIP, 3334) : new UDPTimeServer(3334);
            FNetTimeSync.Start();
        }
Beispiel #24
0
        private static void AssignOptionalPluginInterfaces(IInternalPluginHost pluginHost, IPluginBase pluginBase)
        {
            var win32Window = pluginBase as IWin32Window;

            if (win32Window != null)
            {
                pluginHost.Win32Window = win32Window;
            }
            var pluginConnections = pluginBase as IPluginConnections;

            if (pluginConnections != null)
            {
                pluginHost.Connections = pluginConnections;
            }
            var pluginDXLayer = pluginBase as IPluginDXLayer;

            if (pluginDXLayer != null)
            {
                pluginHost.DXLayer = pluginDXLayer;
            }
            var pluginDXMesh = pluginBase as IPluginDXMesh;

            if (pluginDXMesh != null)
            {
                pluginHost.DXMesh = pluginDXMesh;
            }
            var pluginDXResource = pluginBase as IPluginDXResource;

            if (pluginDXResource != null)
            {
                pluginHost.DXResource = pluginDXResource;
            }
            var pluginTexture = pluginBase as IPluginDXTexture;

            if (pluginTexture != null)
            {
                pluginHost.DXTexture = pluginTexture;
            }
            var pluginTexture2 = pluginBase as IPluginDXTexture2;

            if (pluginTexture2 != null)
            {
                pluginHost.DXTexture2 = pluginTexture2;
            }
        }
Beispiel #25
0
        private static void AssignOptionalPluginInterfaces(IInternalPluginHost pluginHost, IPluginBase pluginBase)
        {
            switch (pluginBase)
            {
            case IWin32Window win32Window:
                pluginHost.Win32Window = win32Window;
                break;

            case IPluginConnections pluginConnections:
                pluginHost.Connections = pluginConnections;
                break;

            case IPluginDXLayer pluginDXLayer:
                pluginHost.DXLayer = pluginDXLayer;
                break;

            case IPluginDXMesh pluginDXMesh:
                pluginHost.DXMesh = pluginDXMesh;
                break;

            case IPluginDXTexture pluginTexture:
                pluginHost.DXTexture = pluginTexture;
                break;

            case IPluginDXTexture2 pluginTexture2:
                pluginHost.DXTexture2 = pluginTexture2;
                break;
            }
            if (pluginBase is IPluginDXResource pluginDXResource)
            {
                pluginHost.DXResource = pluginDXResource;
            }
        }
 public PluginConfiguration(IPluginBase plugin, IContainer container, _Assembly assembly = null)
     : this(assembly)
 {
     Plugin    = plugin ?? throw new ArgumentNullException(nameof(plugin));
     Container = container ?? throw new ArgumentNullException(nameof(container));
 }
Beispiel #27
0
 public CBItem(IPluginBase plugin)
 {
     Plugin = plugin;
 }