Exemplo n.º 1
0
        public void AddCmdWorkItems(WeaveTCPCommand cmd)
        {
            cmd.SetGlobalQueueTable(weaveTable, TcpToken);
            WeaveTCPCommandItem cmdItem = new WeaveTCPCommandItem();

            // Ic.SetGlobalQueueTable(weaveTable, TcpTokenList);
            cmdItem.WeaveTcpCmd = cmd;
            cmdItem.CmdName     = cmd.Getcommand();
            GetAttributeInfo(cmd, cmd.GetType(), cmd);
            weaveTCPCommandItems.Add(cmdItem);
        }
Exemplo n.º 2
0
        public void ReloadFlies()
        {
            try
            {
#if !NETSTANDARD2_0
                String[] strfilelist = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "command");
#else
                String[] strfilelist = System.IO.Directory.GetFiles(AppContext.BaseDirectory + "command");
#endif
                foreach (string file in strfilelist)
                {
                    Assembly ab    = Assembly.LoadFile(file);
                    Type[]   types = ab.GetExportedTypes();
                    foreach (Type t in types)
                    {
                        try
                        {
                            if (t.IsSubclassOf(typeof(WeaveTCPCommand)))
                            {
                                CmdWorkItem     ci  = new CmdWorkItem();
                                object          obj = ab.CreateInstance(t.FullName);
                                WeaveTCPCommand Ic  = obj as WeaveTCPCommand;
                                Ic.SetGlobalQueueTable(weaveTable, TcpTokenList);
                                ci.WeaveTcpCmd = Ic;
                                ci.CmdName     = Ic.Getcommand();
                                GetAttributeInfo(Ic, obj.GetType(), obj);
                                CmdWorkItems.Add(ci);
                            }
                        }
                        catch //(Exception ex)
                        { }
                    }
                }
            }
            catch (Exception ex)
            {
                if (WeaveLogEvent != null)
                {
                    WeaveLogEvent("加载异常", ex.Message);
                }
            }
        }
Exemplo n.º 3
0
 public void GetAttributeInfo(WeaveTCPCommand Ic, Type t, object obj)
 {
     foreach (MethodInfo mi in t.GetMethods())
     {
         InstallFunAttribute myattribute = (InstallFunAttribute)Attribute.GetCustomAttribute(mi, typeof(InstallFunAttribute));
         if (myattribute == null)
         {
         }
         else
         {
             if (myattribute.Dtu)
             {
                 Delegate del = Delegate.CreateDelegate(typeof(WeaveRequestDataDtuDelegate), obj, mi, true);
                 Ic.Bm.AddListen(mi.Name, del as WeaveRequestDataDtuDelegate, myattribute.Type, true);
             }
             else
             {
                 Delegate del = Delegate.CreateDelegate(typeof(WeaveRequestDataDelegate), obj, mi, true);
                 Ic.Bm.AddListen(mi.Name, del as WeaveRequestDataDelegate, myattribute.Type);
             }
         }
     }
 }