Пример #1
0
        public PluginHandle GetNestedPlugin(PluginHandle plugin, int index)
        {
            PluginHandle handle;

            library.System_GetNestedPlugin(Handle, plugin, index, &handle).CheckResult();
            return(handle);
        }
Пример #2
0
        /// <summary>
        ///初始化界面
        /// </summary>
        private void InitialFrm()
        {
            _frmTemp.SysInfo = "获取系统功能插件中...";
            _frmTemp.RefreshLable();
            //从插件文件夹中获取插件接口对象
            PluginHandle     pluginHandle = new PluginHandle(Mod.m_PluginFolderPath);
            PluginCollection pluginCol    = pluginHandle.GetPluginFromDLL();

            //初始化主框架对象
            Mod.v_AppForm = new Fan.Plugin.Application.AppForm(this, pluginCol);
            //分类解析、获取插件
            m_MainPluginUI.IntialModuleCommon(Mod.m_LoginUser, pluginCol);
            //根据用户权限价值窗体
            string strMessage = m_MainPluginUI.LoadForm(Mod.v_AppForm as Fan.Plugin.Application.IApplicationRef);

            if (!string.IsNullOrEmpty(strMessage))
            {
                LogManage.WriteLog(strMessage);
            }
            SysLogInfoChangedEvent newEvent = new SysLogInfoChangedEvent("加载数据...");

            SysLogInfoChnaged(null, newEvent);
            //根据XML加载插件界面
            m_MainPluginUI.LoadData(Mod.v_AppForm as Fan.Plugin.Application.IApplicationRef);
        }
Пример #3
0
        /// <summary>
        /// Executes a plugin method.
        /// </summary>
        /// <param name="pluginHandle">The plugin handle.</param>
        /// <param name="methodName">The method name.</param>
        /// <param name="args">Arguments for the method.</param>
        public static void ExecutePluginMethod(object pluginHandle, string methodName, params object[] args)
        {
            Contract.RequireNotNull(pluginHandle, out object PluginHandle);
            Contract.RequireNotNull(methodName, out string MethodName);

            PluginHandle.GetType().InvokeMember(MethodName, BindingFlags.Default | BindingFlags.InvokeMethod, null, pluginHandle, args, CultureInfo.InvariantCulture);
        }
Пример #4
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainGIS_Load(object sender, EventArgs e)
        {
            //从插件文件夹中获得实现插件接口的对象
            PluginCollection pluginCol = PluginHandle.GetPluginsFromDll();
            //解析这些插件对象,获得不同类型的插件集合
            ParsePluginCollection parsePluhinCol = new ParsePluginCollection();

            parsePluhinCol.GetPluginArray(pluginCol);
            _CommandCol        = parsePluhinCol.GetCommands;
            _ToolCol           = parsePluhinCol.GetTools;
            _ToolBarCol        = parsePluhinCol.GetToolBarDefs;
            _MenuItemCol       = parsePluhinCol.GetMenuDefs;
            _DockableWindowCol = parsePluhinCol.GetDockableWindows;

            //获得Command和Tool在UI层上的Category属性,只是纯粹的分类符号
            //可以根据不同类别插件进行UI级解析,可以编写 为uicommon uitool
            //foreach (string categoryName in parsePluhinCol.GetCommandCategorys)
            //{
            //    //对ui进行分为不同的类别
            //    //uiCommandManager.Categories.Add(new UICommandCategory(categoryName));
            //}
            //产生UI对象
            CreateUICommandTool(_CommandCol, _ToolCol);
            CreateToolBars(_ToolBarCol);
            CreateMenus(_MenuItemCol);
            CreateDockableWindow(_DockableWindowCol);
            //保证宿主程序启动后不存在任何默认的处于使用状态的ITool对象
            _mapControl.CurrentTool        = null;
            _pageLayoutControl.CurrentTool = null;
        }
Пример #5
0
            /// <summary>
            /// Load the plugin.
            /// </summary>
            private void _load(object caller)
            {
                string file = this.File;

                System.Reflection.Assembly assembly = Manager._loadAssembly(file);
                this.Assembly = Assembly;
                if (null == assembly)
                {
                    return;
                }

                using (ClassFactoryHandle factory = new ClassFactoryHandle(Manager._createClassFactory(assembly, file)))
                {
                    if (false == factory.Valid)
                    {
                        return;
                    }

                    using (PluginHandle plugin = new PluginHandle(Manager._createInstance(factory.Value, file)))
                    {
                        this.Handle = plugin.Value;
                        if (false == plugin.Valid)
                        {
                            return;
                        }
                        plugin.Value.start(caller);
                    }
                }
            }
Пример #6
0
        public int GetNestedPluginCount(PluginHandle plugin)
        {
            int count = 0;

            library.System_GetNumNestedPlugins(Handle, plugin, &count).CheckResult();
            return(count);
        }
Пример #7
0
        public DspDescriptionStruct *GetDSPInfoByPlugin(PluginHandle plugin)
        {
            DspDescriptionStruct *ptr;

            library.System_GetDSPInfoByPlugin(Handle, plugin, &ptr).CheckResult();

            return(ptr);
        }
Пример #8
0
        public PluginHandle RegisterCodec(ref Codec.CodecDescriptionStruct description, uint priority = 0)
        {
            PluginHandle handle = default;

            library.System_RegisterCodec(Handle, ref description, &handle, priority).CheckResult();

            return(handle);
        }
Пример #9
0
        public DspHandle CreateDSPByPlugin(PluginHandle plugin)
        {
            DspHandle handle = default;

            library.System_CreateDSPByPlugin(Handle, plugin, &handle).CheckResult();

            return(handle);
        }
Пример #10
0
        /// <summary>
        /// Gets the value of plugin property.
        /// </summary>
        /// <typeparam name="T">The property type.</typeparam>
        /// <param name="pluginHandle">The plugin handle.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The property value.</returns>
        public static T PluginProperty <T>(object pluginHandle, string propertyName)
        {
            Contract.RequireNotNull(pluginHandle, out object PluginHandle);
            Contract.RequireNotNull(propertyName, out string PropertyName);

            object?Result = PluginHandle.GetType().InvokeMember(PropertyName, BindingFlags.Default | BindingFlags.GetProperty, null, pluginHandle, null, CultureInfo.InvariantCulture);

            return((T)Result !);
        }
Пример #11
0
        /// <summary>
        /// Calls a plugin function.
        /// </summary>
        /// <typeparam name="T">The plugin function return type.</typeparam>
        /// <param name="pluginHandle">The plugin handle.</param>
        /// <param name="functionName">The plugin function name.</param>
        /// <param name="args">Arguments for the function.</param>
        /// <returns>The function return value.</returns>
        public static T GetPluginFunctionValue <T>(object pluginHandle, string functionName, params object[] args)
        {
            Contract.RequireNotNull(pluginHandle, out object PluginHandle);
            Contract.RequireNotNull(functionName, out string FunctionName);

            object?Result = PluginHandle.GetType().InvokeMember(FunctionName, BindingFlags.Default | BindingFlags.InvokeMethod, null, pluginHandle, args, CultureInfo.InvariantCulture);

            return((T)Result !);
        }
Пример #12
0
 /// <summary>
 /// Release the plugin.
 /// </summary>
 private void _release(object caller)
 {
     using (PluginHandle plugin = new PluginHandle(this.Handle))
     {
         if (true == plugin.Valid)
         {
             plugin.Value.finish(caller);
         }
     }
     this.Handle   = null;
     this.Assembly = null;
 }
Пример #13
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainGIS_Load(object sender, EventArgs e)
        {
            //从插件文件夹中获得实现插件接口的对象
            PluginCollection pluginCol = PluginHandle.GetPluginsFromDll();
            //解析这些插件对象,获得不同类型的插件集合
            ParsePluginCollection parsePluhinCol = new ParsePluginCollection();

            parsePluhinCol.GetPluginArray(pluginCol);
            _CommandCol        = parsePluhinCol.GetCommands;
            _ToolCol           = parsePluhinCol.GetTools;
            _ToolBarCol        = parsePluhinCol.GetToolBarDefs;
            _MenuItemCol       = parsePluhinCol.GetMenuDefs;
            _DockableWindowCol = parsePluhinCol.GetDockableWindows;

            //获得Command和Tool在UI层上的Category属性,只是纯粹的分类符号
            //可以根据不同类别插件进行UI级解析,可以编写 为uicommon uitool
            //foreach (string categoryName in parsePluhinCol.GetCommandCategorys)
            //{
            //    //对ui进行分为不同的类别
            //    //uiCommandManager.Categories.Add(new UICommandCategory(categoryName));
            //}
            //产生UI对象
            CreateUICommandTool(_CommandCol, _ToolCol);
            CreateToolBars(_ToolBarCol);
            CreateMenus(_MenuItemCol);
            CreateDockableWindow(_DockableWindowCol);
            //保证宿主程序启动后不存在任何默认的处于使用状态的ITool对象
            _mapControl.CurrentTool        = null;
            _pageLayoutControl.CurrentTool = null;

            //主界面系统名称,获取目录下的SystemName.txt[可灵活设置]
            string sUIName = "县域尺度低丘缓坡山地开发土地优化布局系统";

            string sTxtFileName = System.Windows.Forms.Application.StartupPath + "\\SystemName.txt";

            if (!File.Exists(sTxtFileName))
            {
                this.FindForm().Text = sUIName;
                return;
            }

            StreamReader sr = new StreamReader(sTxtFileName, Encoding.Default);
            String       line;

            while ((line = sr.ReadLine()) != null)
            {
                sUIName = line.ToString();
            }
            //this.Name = sUIName;

            this.FindForm().Text = sUIName;
        }
Пример #14
0
        public unsafe PluginInfo GetPluginInfo(PluginHandle plugin)
        {
            const int   buflen = Fmod.MaxInteropNameStringLength;
            byte *      buffer = stackalloc byte[buflen];
            PluginType  type;
            FmodVersion version;

            library.System_GetPluginInfo(Handle, plugin, &type, buffer, buflen, &version).CheckResult();

            string name = FmodHelpers.BufferToString(buffer, buflen);

            return(new PluginInfo(name, type, version));
        }
Пример #15
0
 /// <summary>
 /// Get the interface, or null.
 /// </summary>
 public T get <T>()
 {
     try
     {
         using (PluginHandle plugin = new PluginHandle(this.Handle))
         {
             if (true == plugin.Valid)
             {
                 if (plugin.Value is T)
                 {
                     return((T)plugin.Value);
                 }
             }
         }
     }
     catch (System.InvalidCastException)
     {
     }
     return(default(T));
 }
Пример #16
0
 /// <summary>
 /// Return a new plugin interface.
 /// </summary>
 private static CadKit.Interfaces.IPlugin _createInstance(CadKit.Interfaces.IClassFactory factory, string file)
 {
     try
     {
         object temp = factory.createInstance("CadKit.Interfaces.IPlugin");
         if (null == temp)
         {
             throw new System.Exception(System.String.Format("Error 3887634468: Failed to create plugin instance in assembly file: {0}", file));
         }
         using (PluginHandle plugin = new PluginHandle(temp as CadKit.Interfaces.IPlugin))
         {
             if (false == plugin.Valid)
             {
                 throw new System.Exception(System.String.Format("Error 1228345170: object created in assembly file '{0}' is not a plugin", file));
             }
             return(plugin.release());
         }
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("Error 1716255460: Failed to create plugin interface in assembly file '{0}', {1}", file, e.Message);
         throw;
     }
 }
Пример #17
0
 public void UnloadPlugin(PluginHandle plugin)
 {
     library.System_UnloadPlugin(Handle, plugin).CheckResult();
 }