Ejemplo n.º 1
0
        /// <summary>
        /// 根据反射读取协议dll,并生成协议解析源码
        /// </summary>
        /// <param name="assemblyName"></param>
        public static string AssemblyParseDll(string assemblyName)
        {
            AssemblyHandler handler = new AssemblyHandler();
            AssemblyResult  result  = handler.GetClassName(assemblyName);

            result.AssemblyNameList = new List <string>();
            result.AssemblyNameList.Add(assemblyName);

            string strGenerateCode = GenerateCodeModel.GenerateCode(result.ClassList);
            //string codeFileName = "Client_Code.cs";
            string codeFileName = ConstData.GenrateCodeFileName;

            try
            {
                string       codeFileFullName = PathExt.codePath + ConstData.GenrateCodePathName + codeFileName;
                FileInfo     fCodeFileName    = new FileInfo(codeFileFullName);
                StreamWriter wResponseRecv    = fCodeFileName.CreateText();
                wResponseRecv.WriteLine(strGenerateCode);
                wResponseRecv.Close();

                //codeFileFullName = PathExt.rootPath + ConstData.GenrateCodePathName + codeFileName;
                //fCodeFileName = new FileInfo(codeFileFullName);
                //wResponseRecv = fCodeFileName.CreateText();
                //wResponseRecv.WriteLine(strGenerateCode);
                //wResponseRecv.Close();
            }
            catch (System.Exception e)
            {
                Log.Error("e {0}", e.Message);
            }

            return(strGenerateCode);
        }
Ejemplo n.º 2
0
 public static void GetAsseblyResult(out AssemblyHandler handler, out AssemblyResult result)
 {
     //AssemblyHandler handler = new AssemblyHandler();
     handler = new AssemblyHandler();
     //AssemblyResult result = handler.GetClassName(ClientMsgDll);
     result = handler.GetClassName(ConstData.ServerMsgDll);
     result.AssemblyNameList = new List <string>();
     result.AssemblyNameList.Add(ConstData.ServerMsgDll);
 }
Ejemplo n.º 3
0
        public static string AssemblyParseDll(string assemblyName, out AssemblyResult result)
        {
            AssemblyHandler handler = new AssemblyHandler();

            result = handler.GetClassName(assemblyName);
            result.AssemblyNameList = new List <string>();
            result.AssemblyNameList.Add(assemblyName);

            string       strGenerateCode  = GenerateCodeModel.GenerateCode(result.ClassTypeList);
            string       codeFileName     = "GateServer_Code.cs";
            string       codeFileFullName = @"..\..\Libs\ClientLib\" + codeFileName;
            FileInfo     fCodeFileName    = new FileInfo(codeFileFullName);
            StreamWriter wResponseRecv    = fCodeFileName.CreateText();

            wResponseRecv.WriteLine(strGenerateCode);
            wResponseRecv.Close();

            return(strGenerateCode);
        }
Ejemplo n.º 4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            var height = Height;
            var width  = Width;

            MinimumSize = new Size(width, height);
            MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, height);

            AssemblyHandler handler = new AssemblyHandler();

            mAssemblyResult = handler.GetClassName(protocolMsgDllName);
            foreach (var item in mAssemblyResult.ClassTypeList)
            {
                if (item.Key.Contains("Protocol") && item.Key.Contains("MSG_C2G"))
                {
                    comboBox_ProtocolName.Items.Add(item.Value.Name);
                }
            }
            InitApi();
        }