Beispiel #1
0
        public static PluginServiceImpl Create(string pluginId, string pluginName, string commandText, string commandPattern)
        {
            PluginServiceImpl obj = new PluginServiceImpl();

            byte[] cache = Encoding.Default.GetBytes(pluginId);
            if (cache.Length > 36 || cache.Length == 0)
            {
                throw new Exception("参数错误:pluginId长度应该大于0且小于37");
            }
            obj._info.PluginId = new byte[37];
            Buffer.BlockCopy(cache, 0, obj._info.PluginId, 0, cache.Length);
            obj._info.PluginName = Marshal.StringToHGlobalAnsi(pluginName);
            if (string.IsNullOrEmpty(commandText))
            {
                throw new ArgumentException("参数commandText不能为空");
            }
            obj._info.CommandText = Marshal.StringToHGlobalAnsi(commandText);
            if (!string.IsNullOrEmpty(commandPattern))
            {
                obj._info.CommandMatchPattern = Marshal.StringToHGlobalAnsi(commandPattern);
            }
            obj._info.InitPluginModule   = new PluginFuncInitialize(obj.InitPluginModule);
            obj._info.OnCommandCall      = new PluginFuncCommandCall(obj.OnCommandCall);
            obj._info.PluginInfoFree     = new FuncPluginInfoFree(obj.PluginInfoFree);
            obj._info.UnInitPluginModule = new PluginFuncUnInitialize(obj.UnInitPluginModule);

            maps[obj._key] = obj;//添加到map,增加对obj的引用,防止GC对该实例进行垃圾回收
            return(obj);
        }
Beispiel #2
0
        public static PluginServiceImpl Create(string pluginId,string pluginName,string commandText,string commandPattern)
        {
            PluginServiceImpl obj = new PluginServiceImpl();
            byte[] cache = Encoding.Default.GetBytes(pluginId);
            if (cache.Length > 36 || cache.Length == 0)
            {
                throw new Exception("参数错误:pluginId长度应该大于0且小于37");
            }
            obj._info.PluginId=new byte[37];
            Buffer.BlockCopy(cache, 0, obj._info.PluginId, 0, cache.Length);
            obj._info.PluginName = Marshal.StringToHGlobalAnsi(pluginName);
            if (string.IsNullOrEmpty(commandText))
            {
                throw new ArgumentException("参数commandText不能为空");
            }
            obj._info.CommandText = Marshal.StringToHGlobalAnsi(commandText);
            if (!string.IsNullOrEmpty(commandPattern))
            {
                obj._info.CommandMatchPattern = Marshal.StringToHGlobalAnsi(commandPattern);
            }
            obj._info.InitPluginModule = new PluginFuncInitialize(obj.InitPluginModule);
            obj._info.OnCommandCall = new PluginFuncCommandCall(obj.OnCommandCall);
            obj._info.PluginInfoFree = new FuncPluginInfoFree(obj.PluginInfoFree);
            obj._info.UnInitPluginModule = new PluginFuncUnInitialize(obj.UnInitPluginModule);

            maps[obj._key] = obj;//添加到map,增加对obj的引用,防止GC对该实例进行垃圾回收
            return obj;
        }