Exemplo n.º 1
0
        public static DataStruct GetDataStruct(string name, string module)
        {
            DataStruct struct2 = null;

            if (!DataStructDic.TryGetValue(name, out struct2))
            {
                DataStructDic.TryGetValue(module + "_" + name, out struct2);
            }
            return(struct2);
        }
Exemplo n.º 2
0
 public static void Serialize(ArrayList CommDataStruct, string dir, Label label1)
 {
     if (CommDataStruct.Count != 0)
     {
         string path = dir + @"\XML\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         string str2 = path + "PublicStruct.xml";
         label1.Text = "正在生成文件: " + str2;
         label1.Refresh();
         File.Delete(str2);
         XmlTextWriter writer = new XmlTextWriter(str2, null)
         {
             Formatting  = Formatting.Indented,
             Indentation = 4
         };
         writer.WriteStartDocument();
         writer.WriteStartElement("Root");
         foreach (DataStruct struct2 in CommDataStruct)
         {
             writer.WriteStartElement("Struct");
             writer.WriteAttributeString("Name", struct2.StructName);
             writer.WriteAttributeString("CName", struct2.CNName);
             writer.WriteAttributeString("ProtoType", struct2.getProtoTypeName(struct2.ProtoType));
             writer.WriteAttributeString("Comment", struct2.Comment);
             writer.WriteAttributeString("MaxFieldId", struct2.MaxFieldId.ToString());
             foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
             {
                 writer.WriteStartElement("Field");
                 writer.WriteAttributeString("PreDefine", descriptor.PreDefine.ToString());
                 writer.WriteAttributeString("FieldType", descriptor.FieldType ?? "");
                 writer.WriteAttributeString("Name", descriptor.FieldName);
                 writer.WriteAttributeString("CName", descriptor.CNName);
                 writer.WriteAttributeString("Comment", descriptor.Comment);
                 writer.WriteAttributeString("FieldId", descriptor.FieldId.ToString());
                 writer.WriteAttributeString("ValueSet", descriptor.ValueSet);
                 writer.WriteAttributeString("MinValue", descriptor.MinValue.ToString());
                 writer.WriteAttributeString("MaxValue", descriptor.MaxValue.ToString());
                 if (DataStruct.IsBaseType(descriptor.FieldType))
                 {
                     writer.WriteAttributeString("DefaultValue", descriptor.DefaultValue);
                 }
                 writer.WriteEndElement();
             }
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
         writer.WriteEndDocument();
         writer.Flush();
         writer.Close();
     }
 }
Exemplo n.º 3
0
 public static bool ContainsKey(string name, ref DataStruct ds)
 {
     foreach (DataStruct struct2 in CommDataStruct)
     {
         if (struct2.StructName == name)
         {
             ds = struct2;
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        private static ArrayList GenMessage(DataStruct struct2, ref string str5)
        {
            ArrayList referenceMssage = new ArrayList();

            str5 += "message  " + struct2.getFullName() + "\r\n{\r\n";
            foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
            {
                DataStruct struct3 = null;

                string fieldType = descriptor.FieldType;
                if ((((descriptor.FieldType == "float") || (descriptor.FieldType == "bool")) || ((descriptor.FieldType == "sint32") || (descriptor.FieldType == "sint64"))) && (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional))
                {
                    object obj3 = str5;
                    str5 = string.Concat(new object[] { obj3, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, "[default=", descriptor.DefaultValue, "];\r\n" });
                }
                else if ((((descriptor.FieldType == "uint64"))) && (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional))
                {
                    UInt64 t = 0;
                    if (!UInt64.TryParse(descriptor.DefaultValue, out t))
                    {
                        descriptor.DefaultValue = "0";
                    }
                    object obj3 = str5;
                    str5 = string.Concat(new object[] { obj3, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, "[default=", descriptor.DefaultValue, "];\r\n" });
                }
                else if (descriptor.FieldType == "string")
                {
                    object obj4 = str5;
                    str5 = string.Concat(new object[] { obj4, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, ";\r\n" });
                }
                else
                {
                    object     obj4      = str5;
                    DataStruct refStruct = null;
                    if (DataStructConverter.ContainsKey(fieldType, ref refStruct))
                    {
                        referenceMssage.Add(refStruct);
                    }


                    str5 = string.Concat(new object[] { obj4, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, ";\r\n" });
                }
            }

            str5 = str5 + "\r\n}\r\n\r\n";

            return(referenceMssage);
        }
Exemplo n.º 5
0
 private static void getDataStructName(ArrayList arr, DataStruct ds)
 {
     if (!arr.Contains(ds))
     {
         arr.Add(ds);
         foreach (DataStruct.FieldDescriptor descriptor in ds.fieldItem)
         {
             if (!DataStruct.IsBaseType(descriptor.FieldType) && !arr.Contains(descriptor.FieldType))
             {
                 DataStruct dataStruct = DataStruct.GetDataStruct(descriptor.FieldType, (ds.module == null) ? "" : ds.module.ModuleName);
                 if (dataStruct != null)
                 {
                     getDataStructName(arr, dataStruct);
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 public DataStruct getModuleStruct(string name)
 {
     foreach (DataStruct struct2 in this.moduleDataStruct)
     {
         if (struct2.StructName == name)
         {
             return(struct2);
         }
     }
     foreach (object obj2 in DataStructConverter.CommDataStruct)
     {
         DataStruct struct3 = (DataStruct)obj2;
         if (struct3.StructName == name)
         {
             return(struct3);
         }
     }
     return(null);
 }
Exemplo n.º 7
0
        private static void DiGui(ref Module m, ref string RpcValues, string name, bool isSave)
        {
            bool       flag    = false;
            DataStruct struct2 = m.getModuleStruct(name);

            if ((struct2 != null) && !map.ContainsKey(name))
            {
                if (((struct2.DataType == DataStruct.SyncType.UserData) || (struct2.DataType == DataStruct.SyncType.CacheData)) || (struct2.DataType == DataStruct.SyncType.ModuleData))
                {
                    flag = true;
                }
                map.Add(name, 1);
                string str = "";
                str = ((str + "      message  " + name) + (flag ? ("V" + m.SyncDataVersion) : "") + "\r\n") + "      {\r\n";
                foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
                {
                    str = str + "        " + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "repeated" : "optional");
                    str = str + " " + descriptor.FieldType;
                    if (("sint32" != descriptor.FieldType) && ("sint64" != descriptor.FieldType) || ("uint64" != descriptor.FieldType))
                    {
                        bool flag1 = "string" == descriptor.FieldType;
                    }
                    object obj2 = str;
                    str = string.Concat(new object[] { obj2, " ", descriptor.FieldName, " = ", descriptor.FieldId });
                    if ((("sint32" == descriptor.FieldType) || ("sint64" == descriptor.FieldType) || ("uint64" == descriptor.FieldType)) && (descriptor.PreDefine != DataStruct.FieldDescriptor.PreDefineType.repeated))
                    {
                        str = str + "[default=" + descriptor.defaultValue + "]";
                    }
                    str = str + ";\r\n";
                    if ((("sint32" != descriptor.FieldType) && ("sint64" != descriptor.FieldType) || ("uint64" == descriptor.FieldType)) && ("string" != descriptor.FieldType))
                    {
                        DiGui(ref m, ref RpcValues, descriptor.FieldType, isSave);
                    }
                }
                str       = str + "      }\r\n";
                RpcValues = RpcValues + str;
            }
        }
Exemplo n.º 8
0
        public static void LookFor(Module m, string names, string shuoming, string t, ref string writesV, ref Save save, int mytype)
        {
            DataStruct struct2 = null;

            if (!DataStruct.DataStructDic.TryGetValue(names, out struct2))
            {
                DataStruct.DataStructDic.TryGetValue(m.ModuleName + names, out struct2);
            }
            if (struct2 == null)
            {
                struct2 = m.getModuleStruct(names);
            }
            if (struct2 != null)
            {
                string str = (t == "") ? struct2.getFullName() : (t + "[" + names + "]");
                writesV = writesV + str;
                byte[] bytes  = Encoding.Default.GetBytes(struct2.CNName);
                int    length = bytes.Length;
                bw.Write(length);
                bw.Write(bytes, 0, length);
                bw.Write(names.Length);
                bw.Write(names.ToCharArray(0, names.Length));
                Module.OperaterItem.SubOperaterItem subOperaterItem = m.GetSubOperaterItem(names, "");
                if (subOperaterItem == null)
                {
                    bw.Write(false);
                    bw.Write(false);
                }
                else if (subOperaterItem.Type == Module.OperateType.OP_ASK)
                {
                    bw.Write(true);
                    bw.Write(false);
                    writesV = writesV + "↑ " + struct2.CNName;
                }
                else if (subOperaterItem.Type == Module.OperateType.OP_REPLY)
                {
                    bw.Write(false);
                    bw.Write(true);
                    writesV = writesV + "↓ " + struct2.CNName;
                }
                else if (subOperaterItem.Type == Module.OperateType.OP_CLIENT_NOTIFY)
                {
                    bw.Write(true);
                    bw.Write(false);
                    writesV = writesV + "↑ " + struct2.CNName;
                }
                else if (subOperaterItem.Type == Module.OperateType.OP_SERVER_NOTIFY)
                {
                    bw.Write(false);
                    bw.Write(true);
                    writesV = writesV + "↓ " + struct2.CNName;
                }
                else
                {
                    bw.Write(true);
                    bw.Write(true);
                    writesV = writesV + "↑↓ " + struct2.CNName;
                }
                writesV = writesV + "\r\n";
                bw.Write(mytype);
                bw.Write(struct2.fieldItem.Count);
                foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
                {
                    bw.Write(names.Length);
                    bw.Write(names.ToCharArray(0, names.Length));
                    save.Name = descriptor.FieldName;
                    int num2 = save.Name.Length;
                    bw.Write(num2);
                    bw.Write(save.Name.ToCharArray(0, num2));
                    save.Repet = descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated;
                    bw.Write(save.Repet);
                    save.Value = "";
                    if ((((descriptor.FieldType == "bool") || (descriptor.FieldType == "float")) || ((descriptor.FieldType == "sint32") || (descriptor.FieldType == "sint64") || (descriptor.FieldType == "uint64"))) && (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional))
                    {
                        save.Value = "[" + descriptor.DefaultValue + "]";
                    }
                    num2 = save.Value.Length;
                    bw.Write(num2);
                    bw.Write(save.Value.ToCharArray(0, num2));
                    save.CNName = descriptor.CNName;
                    byte[] buffer = Encoding.Default.GetBytes(save.CNName);
                    num2 = buffer.Length;
                    bw.Write(num2);
                    bw.Write(buffer, 0, num2);
                    save.Type = descriptor.FieldType;
                    num2      = save.Type.Length;
                    bw.Write(num2);
                    bw.Write(save.Type.ToCharArray(0, num2));
                    if (descriptor.FieldType == "string")
                    {
                        bw.Write(false);
                        string str3 = writesV;
                        writesV = str3 + t + "\t" + descriptor.FieldName + ":string" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else if (descriptor.FieldType == "bytes")
                    {
                        bw.Write(false);
                        string str4 = writesV;
                        writesV = str4 + t + "\t" + descriptor.FieldName + ":bytes" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else if (descriptor.FieldType == "bool")
                    {
                        bw.Write(false);
                        string str5 = writesV;
                        writesV = str5 + t + "\t" + descriptor.FieldName + ":bool" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else if (descriptor.FieldType == "float")
                    {
                        bw.Write(false);
                        string str6 = writesV;
                        writesV = str6 + t + "\t" + descriptor.FieldName + ":float" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else if (descriptor.FieldType == "sint32")
                    {
                        bw.Write(false);
                        string str7 = writesV;
                        writesV = str7 + t + "\t" + descriptor.FieldName + ":int32" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else if (descriptor.FieldType == "sint64")
                    {
                        bw.Write(false);
                        string str8 = writesV;
                        writesV = str8 + t + "\t" + descriptor.FieldName + ":sint64" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else if (descriptor.FieldType == "uint64")
                    {
                        bw.Write(false);
                        string str8 = writesV;
                        writesV = str8 + t + "\t" + descriptor.FieldName + ":uint64" + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + ((descriptor.DefaultValue == "") ? "" : (" = " + descriptor.DefaultValue)) + "\t;" + descriptor.CNName + "\r\n";
                    }
                    else
                    {
                        bw.Write(true);
                        string str9 = writesV;
                        writesV = str9 + t + "\t" + descriptor.FieldName + ":" + descriptor.FieldType + ((descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated) ? "*" : "") + "\t;" + descriptor.CNName + "\r\n";
                        string str2 = t + "\t";
                        save.Next = new Save();
                        Save next = save.Next;
                        LookFor(m, descriptor.FieldType, "", str2, ref writesV, ref next, mytype);
                    }
                }
            }
        }
Exemplo n.º 9
0
        private static ArrayList GenMessage(DataStruct struct2, DataStruct.protoTypeE protoType, ref string str5, Module m, ref bool flag)
        {
            ArrayList referenceMssage = new ArrayList();

            if ((struct2.ProtoType == protoType) && ((struct2.StructName.ToLower().IndexOf("svrrpc") <= -1) || (protoType != DataStruct.protoTypeE.RpcProto)))
            {
                if (protoType == DataStruct.protoTypeE.RpcProto)
                {
                    str5 = str5 + "message  " + struct2.getFullName() + "\r\n{\r\n";
                }
                else
                {
                    object obj2 = str5;
                    str5 = string.Concat(new object[] { obj2, "message  ", struct2.getFullName(), "V", m.SyncDataVersion, "\r\n{\r\n" });
                    if ((struct2.DataType == DataStruct.SyncType.UserData) || ((struct2.DataType == DataStruct.SyncType.CacheData) && struct2.SyncToClient))
                    {
                        flag = true;
                    }
                }
                string temp = "";
                foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
                {
                    DataStruct struct3   = null;
                    bool       flag2     = DataStruct.DataStructDic.TryGetValue(descriptor.FieldType, out struct3) || DataStruct.DataStructDic.TryGetValue(m.ModuleName + descriptor.FieldType, out struct3);
                    string     fieldType = descriptor.FieldType;
                    if (flag2)
                    {
                        fieldType = struct3.getFullName();
                        DataStruct ds = null;
                        if (!DataStructConverter.ContainsKey(descriptor.FieldType, ref ds) && (protoType == DataStruct.protoTypeE.SyncProto))
                        {
                            fieldType = fieldType + "V" + m.SyncDataVersion;
                        }
                    }
                    if ((((descriptor.FieldType == "float") || (descriptor.FieldType == "bool")) || ((descriptor.FieldType == "sint32") || (descriptor.FieldType == "sint64"))) && (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional))
                    {
                        object obj3 = str5;
                        str5 = string.Concat(new object[] { obj3, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, "[default=", descriptor.DefaultValue, "];\r\n" });
                    }
                    else if ((((descriptor.FieldType == "uint64"))) && (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional))
                    {
                        UInt64 t = 0;
                        if (!UInt64.TryParse(descriptor.DefaultValue, out t))
                        {
                            descriptor.DefaultValue = "0";
                        }
                        object obj3 = str5;
                        str5 = string.Concat(new object[] { obj3, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, "[default=", descriptor.DefaultValue, "];\r\n" });
                    }
                    else if (descriptor.FieldType == "string")
                    {
                        object obj4 = str5;
                        str5 = string.Concat(new object[] { obj4, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, ";\r\n" });
                    }
                    else
                    {
                        object     obj4      = str5;
                        DataStruct refStruct = null;
                        if (DataStructConverter.ContainsKey(fieldType, ref refStruct))
                        {
                            //temp += "," + fieldType;
                            //MessageBox.Show(fieldType + "__" + refStruct.getFullName());
                            referenceMssage.Add(refStruct);
                        }


                        str5 = string.Concat(new object[] { obj4, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, ";\r\n" });
                    }
                }

                str5 = str5 + "\r\n}\r\n\r\n";
            }
            return(referenceMssage);
        }
Exemplo n.º 10
0
 public static void SerializeCS(Module m, string dir, Label label1, DataStruct.protoTypeE protoType)
 {
     if (GenLangFlags.CS || GenLangFlags.CSCat)
     {
         string path = dir + @"\Proto\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         string ns        = "";
         string str3      = "";
         string shortName = "";
         if (protoType == DataStruct.protoTypeE.RpcProto)
         {
             ns        = "RpcProtoBuf";
             str3      = path + m.ModuleName + "Rpc.proto";
             shortName = m.ModuleName + "Rpc.cs";
         }
         else
         {
             ns        = "SyncProtoBuf";
             str3      = string.Concat(new object[] { path, m.ModuleName, "V", m.SyncDataVersion, "Data.proto" });
             shortName = string.Concat(new object[] { m.ModuleName, "V", m.SyncDataVersion, "Data.cs" });
         }
         label1.Text = "正在生成文件: " + str3;
         label1.Refresh();
         bool   flag = false;
         string str5 = "";
         str5 = str5 + "\r\nimport \"PublicStruct.proto\";\r\n\r\n";
         foreach (DataStruct struct2 in m.moduleDataStruct)
         {
             if ((struct2.ProtoType == protoType) && ((struct2.StructName.ToLower().IndexOf("svrrpc") <= -1) || (protoType != DataStruct.protoTypeE.RpcProto)))
             {
                 if (struct2.Comment != "")
                 {
                     string str7 = str5;
                     str5 = str7 + "/*\r\n" + ((struct2.CNName == "") ? "" : (struct2.CNName + "\r\n")) + struct2.Comment.Replace("\r\n", "\t\r\n") + "\r\n*/\r\n";
                 }
                 else if (struct2.CNName != "")
                 {
                     str5 = str5 + "//" + struct2.CNName + "\r\n";
                 }
                 if (protoType == DataStruct.protoTypeE.RpcProto)
                 {
                     str5 = str5 + "message  " + struct2.getFullName() + "\r\n{\r\n";
                 }
                 else
                 {
                     object obj2 = str5;
                     str5 = string.Concat(new object[] { obj2, "message  ", struct2.getFullName(), "V", m.SyncDataVersion, "\r\n{\r\n" });
                     if ((struct2.DataType == DataStruct.SyncType.UserData) || ((struct2.DataType == DataStruct.SyncType.CacheData) && struct2.SyncToClient))
                     {
                         flag = true;
                     }
                 }
                 foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
                 {
                     DataStruct struct3   = null;
                     bool       flag2     = DataStruct.DataStructDic.TryGetValue(descriptor.FieldType, out struct3) || DataStruct.DataStructDic.TryGetValue(m.ModuleName + descriptor.FieldType, out struct3);
                     string     fieldType = descriptor.FieldType;
                     if (flag2)
                     {
                         fieldType = struct3.getFullName();
                         DataStruct ds = null;
                         if (!DataStructConverter.ContainsKey(descriptor.FieldType, ref ds) && (protoType == DataStruct.protoTypeE.SyncProto))
                         {
                             fieldType = fieldType + "V" + m.SyncDataVersion;
                         }
                     }
                     if (descriptor.Comment != "")
                     {
                         string str8 = str5;
                         str5 = str8 + "\t/*\r\n" + ((descriptor.CNName == "") ? "" : ("\t" + descriptor.CNName + "\r\n")) + "\t" + descriptor.Comment.Replace("\r\n", "\r\n\t") + "\r\n\t*/\r\n";
                     }
                     if ((((descriptor.FieldType == "float") || (descriptor.FieldType == "bool")) || ((descriptor.FieldType == "sint32") || (descriptor.FieldType == "sint64") || (descriptor.FieldType == "uint64"))) && (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional))
                     {
                         object obj3 = str5;
                         str5 = string.Concat(new object[] { obj3, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, "[default=", descriptor.DefaultValue, "];" });
                     }
                     else
                     {
                         object obj4 = str5;
                         str5 = string.Concat(new object[] { obj4, "\t", descriptor.PreDefine, " ", fieldType, " ", descriptor.FieldName, " = ", descriptor.FieldId, ";" });
                     }
                     str5 = str5 + (((descriptor.Comment == "") && (descriptor.CNName != "")) ? ("\t//" + descriptor.CNName) : "") + "\r\n";
                 }
                 str5 = str5 + "}\r\n\r\n";
             }
         }
         if (flag || (protoType != DataStruct.protoTypeE.SyncProto))
         {
             StreamWriter writer = new StreamWriter(str3, false, Encoding.GetEncoding("GBK"));
             writer.Write(str5);
             writer.Flush();
             writer.Close();
             ProtocCS(ns, dir, str3, m.ModuleName, shortName);
         }
     }
 }
Exemplo n.º 11
0
        public static void Serialize(Module m, string dir, Label label1)
        {
            DrawPic.Draw(m);
            string path = dir + @"\XML\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string filename = path + m.ModuleName + ".xml";

            label1.Text = "正在生成文件: " + filename;
            label1.Refresh();
            XmlTextWriter writer = new XmlTextWriter(filename, null)
            {
                Formatting  = Formatting.Indented,
                Indentation = 4
            };

            writer.WriteStartDocument();
            writer.WriteStartElement("Root");
            writer.WriteAttributeString("Module", m.ModuleName);
            writer.WriteAttributeString("CName", m.CNName);
            writer.WriteAttributeString("MsgNumStart", m.StartIdNum.ToString());
            writer.WriteAttributeString("SyncDataVersion", m.SyncDataVersion.ToString());
            writer.WriteAttributeString("Comment", m.Comment);
            int num = 0;

            foreach (Module.OperaterItem item in m.operateItem)
            {
                writer.WriteStartElement("Operate");
                writer.WriteAttributeString("Name", item.Name);
                writer.WriteAttributeString("CName", item.CNName);
                writer.WriteAttributeString("Comment", item.Comment);
                foreach (Module.OperaterItem.SubOperaterItem item2 in item.subOperateItem)
                {
                    writer.WriteStartElement(item2.Type.ToString());
                    writer.WriteAttributeString("Name", item2.Name);
                    writer.WriteAttributeString("CName", item2.CNName);
                    writer.WriteAttributeString("MsgID", (m.StartIdNum + num++).ToString());
                    writer.WriteAttributeString("DataStruct", item2.DataStructName);
                    writer.WriteAttributeString("Comment", item2.Comment);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            foreach (DataStruct struct2 in m.moduleDataStruct)
            {
                writer.WriteStartElement("Struct");
                writer.WriteAttributeString("Name", struct2.StructName);
                writer.WriteAttributeString("CName", struct2.CNName);
                writer.WriteAttributeString("ProtoType", struct2.getProtoTypeName(struct2.ProtoType));
                writer.WriteAttributeString("Comment", struct2.Comment);
                writer.WriteAttributeString("DataType", struct2.DataType.ToString());
                writer.WriteAttributeString("SaveToDB", struct2.SaveToDB.ToString());
                writer.WriteAttributeString("SyncToClient", struct2.SyncToClient.ToString());
                writer.WriteAttributeString("MaxFieldId", struct2.MaxFieldId.ToString());
                foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
                {
                    writer.WriteStartElement("Field");
                    writer.WriteAttributeString("PreDefine", descriptor.PreDefine.ToString());
                    writer.WriteAttributeString("FieldType", descriptor.FieldType ?? "");
                    writer.WriteAttributeString("FieldId", descriptor.FieldId.ToString());
                    writer.WriteAttributeString("Name", descriptor.FieldName);
                    writer.WriteAttributeString("CName", descriptor.CNName);
                    writer.WriteAttributeString("ValueSet", descriptor.ValueSet);
                    writer.WriteAttributeString("MinValue", descriptor.MinValue.ToString());
                    writer.WriteAttributeString("MaxValue", descriptor.MaxValue.ToString());
                    if (DataStruct.IsBaseType(descriptor.FieldType))
                    {
                        writer.WriteAttributeString("DefaultValue", descriptor.DefaultValue);
                    }
                    writer.WriteAttributeString("Comment", descriptor.Comment);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            foreach (ConfigFile file in m.configFiles)
            {
                writer.WriteStartElement("ConfigFile");
                writer.WriteAttributeString("Name", file.ConfigName);
                writer.WriteAttributeString("CName", file.CNName);
                writer.WriteAttributeString("Comment", file.Comment);
                foreach (ConfigFile.ConfigField field in file.fieldItem)
                {
                    writer.WriteStartElement("Field");
                    writer.WriteAttributeString("IsDes", field.IsDescribe.ToString());
                    writer.WriteAttributeString("IsSvr", field.IsServer.ToString());
                    writer.WriteAttributeString("IsPri", field.IsPrimary.ToString());
                    writer.WriteAttributeString("CheckIndex", field.CheckIndex ?? "");
                    writer.WriteAttributeString("MaxValue", field.MaxValue.ToString());
                    writer.WriteAttributeString("MinValue", field.MinValue.ToString());
                    writer.WriteAttributeString("DefaultValue", field.DefaultValue ?? "");
                    writer.WriteAttributeString("ValueSet", field.ValueSet ?? "");
                    writer.WriteAttributeString("FieldType", field.FieldType ?? "");
                    writer.WriteAttributeString("Name", field.FieldName);
                    writer.WriteAttributeString("CName", field.CNName);
                    writer.WriteAttributeString("Comment", field.Comment);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            writer.Close();
        }
Exemplo n.º 12
0
        public static void Deserialize(TreeView tree, string dir)
        {
            DirectoryInfo info = new DirectoryInfo(dir + "/XML");

            if (info.Exists)
            {
                foreach (FileInfo info2 in info.GetFiles())
                {
                    if (((info2.Extension == ".xml") && (info2.Name != "Module.xml")) && (info2.Name != "ProtocolConfig.xml"))
                    {
                        XmlDocument document = new XmlDocument();
                        document.Load(info2.FullName);
                        TreeNode node  = tree.Nodes[0];
                        TreeNode node2 = tree.Nodes[1];
                        if (info2.Name == "PublicStruct.xml")
                        {
                            foreach (XmlNode node3 in document.SelectSingleNode("Root").ChildNodes)
                            {
                                DataStruct struct2 = new DataStruct();
                                XmlElement element = (XmlElement)node3;
                                struct2.StructName = element.GetAttribute("Name");
                                struct2.CNName     = element.GetAttribute("CName");
                                struct2.ProtoType  = struct2.getProtoTypeValue(element.GetAttribute("ProtoType"));
                                struct2.Comment    = element.GetAttribute("Comment");
                                struct2.MaxFieldId = Convert.ToInt32(element.GetAttribute("MaxFieldId"));
                                TreeNode node4 = node.Nodes.Add(struct2.StructName);
                                node4.Name       = "NewDataStruct";
                                node4.ImageIndex = 2;
                                node4.Tag        = struct2;
                                foreach (XmlNode node5 in node3)
                                {
                                    XmlElement element2 = (XmlElement)node5;
                                    DataStruct.FieldDescriptor descriptor = new DataStruct.FieldDescriptor {
                                        dataStruct = struct2
                                    };
                                    struct2.fieldItem.Add(descriptor);
                                    descriptor.FieldName = element2.GetAttribute("Name");
                                    descriptor.CNName    = element2.GetAttribute("CName");
                                    descriptor.FieldType = element2.GetAttribute("FieldType");
                                    descriptor.Comment   = element2.GetAttribute("Comment");
                                    descriptor.FieldId   = Convert.ToInt32(element2.GetAttribute("FieldId"));
                                    descriptor.ValueSet  = element2.GetAttribute("ValueSet");
                                    descriptor.MaxValue  = Convert.ToInt32(element2.GetAttribute("MaxValue"));
                                    descriptor.MinValue  = Convert.ToInt32(element2.GetAttribute("MinValue"));
                                    string attribute = element2.GetAttribute("PreDefine");
                                    descriptor.PreDefine = (attribute == "optional") ? DataStruct.FieldDescriptor.PreDefineType.optional : DataStruct.FieldDescriptor.PreDefineType.repeated;
                                    if (DataStruct.IsBaseType(descriptor.FieldType))
                                    {
                                        descriptor.DefaultValue = element2.GetAttribute("DefaultValue");
                                    }
                                    TreeNode node6 = node4.Nodes.Add(descriptor.FieldName);
                                    node6.Name       = "NewField";
                                    node6.ImageIndex = 3;
                                    node6.Tag        = descriptor;
                                }
                                DataStructConverter.CommDataStruct.Add(struct2);
                                DataStruct.DataStructDic.Add(struct2.getFullName(), struct2);
                            }
                        }
                        else
                        {
                            Module     module   = new Module();
                            XmlElement element3 = (XmlElement)document.SelectSingleNode("Root");
                            module.ModuleName      = element3.GetAttribute("Module");
                            module.CNName          = element3.GetAttribute("CName");
                            module.Comment         = element3.GetAttribute("Comment");
                            module.StartIdNum      = Convert.ToInt32(element3.GetAttribute("MsgNumStart"));
                            module.SyncDataVersion = Convert.ToInt32(element3.GetAttribute("SyncDataVersion"));
                            Module.ModuleDic.Add(module.ModuleName, module);
                            TreeNode node7      = node2.Nodes.Add(module.ModuleName);
                            int      startIdNum = module.StartIdNum;
                            if (startIdNum == 0)
                            {
                                startIdNum = new Random().Next(0x3e8, 0x270f);
                            }
                            ArrayList list2 = new ArrayList();
                            Module.errorDic.Add(startIdNum, list2);
                            Module.ErrorModuleName name = new Module.ErrorModuleName {
                                en = module.ModuleName,
                                cn = module.CNName
                            };
                            Module.moduleNameDic.Add(startIdNum, name);
                            node7.Name       = "NewModule";
                            node7.ImageIndex = 4;
                            node7.Tag        = module;
                            TreeNode node8 = node7.Nodes.Add("Client RPC");
                            node8.Name = "clientRpc";
                            TreeNode node9 = node7.Nodes.Add("RPC Parameters");
                            node9.Name = "rpcProto";
                            TreeNode node10 = node7.Nodes.Add("Module Data");
                            node10.Name = "syncData";
                            TreeNode node11 = node7.Nodes.Add("Configuration Files");
                            node11.Name         = "configFile";
                            module.rpcProtoNode = node9;
                            foreach (XmlNode node12 in document.SelectSingleNode("Root").ChildNodes)
                            {
                                if (node12.Name == "Operate")
                                {
                                    XmlElement          element4 = (XmlElement)node12;
                                    Module.OperaterItem item     = new Module.OperaterItem {
                                        module = module
                                    };
                                    module.operateItem.Add(item);
                                    item.Name    = element4.GetAttribute("Name");
                                    item.CNName  = element4.GetAttribute("CName");
                                    item.Comment = element4.GetAttribute("Comment");
                                    TreeNode node13 = node8.Nodes.Add(item.Name);
                                    node13.Name       = "NewOperate";
                                    node13.ImageIndex = 5;
                                    node13.Tag        = item;
                                    foreach (XmlNode node14 in node12)
                                    {
                                        XmlElement element5 = (XmlElement)node14;
                                        Module.OperaterItem.SubOperaterItem item2 = new Module.OperaterItem.SubOperaterItem();
                                        item.subOperateItem.Add(item2);
                                        item2.operaterItem = item;
                                        item2.Type         = item2.getOperateType(element5.Name);
                                        item2.toSetOpType(element5.Name);
                                        item2.toSetName(element5.GetAttribute("Name"));
                                        item2.toSetCnName(element5.GetAttribute("CName"));
                                        item2.Comment = element5.GetAttribute("Comment");
                                        item2.toSetDataStructName(element5.GetAttribute("DataStruct"));
                                        TreeNode node15 = node13.Nodes.Add(element5.GetAttribute("Name"));
                                        node15.Name       = "NewSubOperate";
                                        node15.ImageIndex = 6;
                                        node15.Tag        = item2;
                                    }
                                }
                                else if (node12.Name == "Struct")
                                {
                                    TreeNode   node16;
                                    XmlElement element6 = (XmlElement)node12;
                                    DataStruct struct3  = new DataStruct {
                                        module = module
                                    };
                                    module.moduleDataStruct.Add(struct3);
                                    struct3.StructName = element6.GetAttribute("Name");
                                    struct3.CNName     = element6.GetAttribute("CName");
                                    struct3.Comment    = element6.GetAttribute("Comment");
                                    struct3.MaxFieldId = Convert.ToInt32(element6.GetAttribute("MaxFieldId"));
                                    struct3.ProtoType  = struct3.getProtoTypeValue(element6.GetAttribute("ProtoType"));
                                    struct3.ToSetDataType(struct3.ConvertDataType(element6.GetAttribute("DataType")));
                                    struct3.saveToDB     = element6.GetAttribute("SaveToDB").ToLower() == "true";
                                    struct3.SyncToClient = element6.GetAttribute("SyncToClient").ToLower() == "true";
                                    if (struct3.ProtoType == DataStruct.protoTypeE.RpcProto)
                                    {
                                        node16 = node9.Nodes.Add(struct3.StructName);
                                    }
                                    else
                                    {
                                        node16 = node10.Nodes.Add(struct3.StructName);
                                    }
                                    node16.Name          = "NewDataStruct";
                                    node16.ImageIndex    = 2;
                                    node16.Tag           = struct3;
                                    struct3.selfTreeNode = node16;
                                    foreach (XmlNode node17 in node12)
                                    {
                                        XmlElement element7 = (XmlElement)node17;
                                        DataStruct.FieldDescriptor descriptor2 = new DataStruct.FieldDescriptor {
                                            dataStruct = struct3
                                        };
                                        struct3.fieldItem.Add(descriptor2);
                                        descriptor2.FieldName = element7.GetAttribute("Name");
                                        descriptor2.CNName    = element7.GetAttribute("CName");
                                        descriptor2.Comment   = element7.GetAttribute("Comment");
                                        descriptor2.FieldType = element7.GetAttribute("FieldType");
                                        descriptor2.FieldId   = Convert.ToInt32(element7.GetAttribute("FieldId"));
                                        string str2 = element7.GetAttribute("PreDefine");
                                        descriptor2.PreDefine = (str2 == "optional") ? DataStruct.FieldDescriptor.PreDefineType.optional : DataStruct.FieldDescriptor.PreDefineType.repeated;
                                        descriptor2.ValueSet  = element7.GetAttribute("ValueSet");
                                        descriptor2.MaxValue  = Convert.ToInt32(element7.GetAttribute("MaxValue"));
                                        descriptor2.MinValue  = Convert.ToInt32(element7.GetAttribute("MinValue"));
                                        if (DataStruct.IsBaseType(descriptor2.FieldType))
                                        {
                                            descriptor2.DefaultValue = element7.GetAttribute("DefaultValue");
                                        }
                                        TreeNode node18 = node16.Nodes.Add(descriptor2.FieldName);
                                        node18.Name       = "NewField";
                                        node18.ImageIndex = 3;
                                        node18.Tag        = descriptor2;
                                    }
                                    DataStruct.DataStructDic.Add(struct3.getFullName(), struct3);
                                }
                                else if (node12.Name == "ConfigFile")
                                {
                                    XmlElement element8 = (XmlElement)node12;
                                    ConfigFile file     = new ConfigFile {
                                        module = module
                                    };
                                    module.configFiles.Add(file);
                                    file.toSetConfigName(element8.GetAttribute("Name"));
                                    file.CNName  = element8.GetAttribute("CName");
                                    file.Comment = element8.GetAttribute("Comment");
                                    TreeNode node19 = node11.Nodes.Add(file.ConfigName);
                                    node19.Name       = "NewConfigFile";
                                    node19.ImageIndex = 2;
                                    node19.Tag        = file;
                                    foreach (XmlNode node20 in node12)
                                    {
                                        XmlElement             element9 = (XmlElement)node20;
                                        ConfigFile.ConfigField field    = new ConfigFile.ConfigField {
                                            configFile = file
                                        };
                                        file.fieldItem.Add(field);
                                        field.toSetFieldName(element9.GetAttribute("Name"));
                                        field.toSetCnName(element9.GetAttribute("CName"));
                                        field.toSetComment(element9.GetAttribute("Comment"));
                                        field.toSetFieldType(element9.GetAttribute("FieldType"));
                                        field.toSetDefaultValue(element9.GetAttribute("DefaultValue"));
                                        field.toSetCheckIndex(element9.GetAttribute("CheckIndex"));
                                        field.toSetValueSet(element9.GetAttribute("ValueSet"));
                                        field.toSetIsPri(element9.GetAttribute("IsPri").ToLower() == "true");
                                        field.toSetIsSvr(element9.GetAttribute("IsSvr").ToLower() == "true");
                                        field.toSetIsDes(element9.GetAttribute("IsDes").ToLower() == "true");
                                        field.toSetMaxValue(Convert.ToInt32(element9.GetAttribute("MaxValue")));
                                        field.toSetMinValue(Convert.ToInt32(element9.GetAttribute("MinValue")));
                                        TreeNode node21 = node19.Nodes.Add(field.FieldName);
                                        node21.Name       = "NewConfigField";
                                        node21.ImageIndex = 3;
                                        node21.Tag        = field;
                                    }
                                    ConfigFile.ConfigFileDic[file.ConfigName] = file;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
 public static void Serialize(Module m, string dir, Label label1)
 {
     if (GenLangFlags.Coffee)
     {
         string path = dir + @"\COFFEE\" + m.ModuleName + @"\";
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         string str2 = dir + @"\COFFEE\Config\";
         if (!Directory.Exists(str2))
         {
             Directory.CreateDirectory(str2);
         }
         StreamReader reader = new StreamReader("./Template/Model.coffee", Encoding.GetEncoding("GBK"));
         reader.ReadToEnd();
         reader.Close();
         ArrayList list = new ArrayList {
             "./Template/Model.coffee",
             "./Template/Controller.coffee"
         };
         ArrayList list2 = new ArrayList {
             path + m.ModuleName + "Model.coffee",
             path + m.ModuleName + "Controller.coffee"
         };
         ArrayList list3 = new ArrayList();
         for (int i = 0; i < list.Count; i++)
         {
             try
             {
                 StreamReader reader2 = null;
                 reader2 = new StreamReader((string)list[i], Encoding.UTF8);
                 string str3 = reader2.ReadToEnd();
                 list3.Add(str3);
                 reader2.Close();
             }
             catch (DirectoryNotFoundException)
             {
                 return;
             }
         }
         label1.Text = "正在生成文件: " + path + m.ModuleName + ".coffee";
         label1.Refresh();
         string operationDeclare   = "";
         string operationImpl      = "";
         string operationImplement = "";
         string text1            = m.SyncDataVersion.ToString();
         string syncIds          = "";
         string syncOpDefine     = "";
         string syncOpImp        = "";
         string sendAllFields    = "";
         string dBCacheField     = "";
         string fromMemoryStream = "";
         string updataValue      = "";
         string rpcValues        = "";
         string toMemoryStream   = "";
         string callBack         = "";
         string callBackARGS     = "";
         string initController   = "";
         string contCallBacks    = "";
         string layer            = "";
         string layerCtor        = "";
         string layerCtoF        = "";
         string enterLayer       = "";
         string enterFunctions   = "";
         string enterFunctionsF  = "";
         string testProtocol     = "";
         string testArgs         = "";
         string getValue         = "";
         bool   flag             = false;
         int    num   = 0;
         int    num3  = 0;
         string str29 = "\tMODULE_ID_" + m.ModuleName.ToUpper();
         int    num4  = 0x2e - str29.Length;
         while (num4-- > 0)
         {
             str29 = str29 + " ";
         }
         object obj2 = str29;
         str29        = string.Concat(new object[] { obj2, "= ", m.StartIdNum, ",\t//", m.CNName, "模块ID\r\n" });
         num          = (m.StartIdNum * 100) + 0x33;
         enterLayer   = "\tlocal btnChat = nil\r\n";
         num3         = 1;
         layerCtor    = "";
         testProtocol = testProtocol + "askList." + m.ModuleName + " = {}\r\n";
         object obj3 = operationImpl;
         operationImpl = string.Concat(new object[] { obj3, "ModuleId = ", m.StartIdNum, "\r\n" });
         testArgs      = testArgs + "      'AskName': [";
         string str30 = "      'ParamterList': [";
         string str31 = "      'AskList':[";
         string str32 = "      'ParamterTypelist': [";
         map = new Dictionary <string, int>();
         foreach (Module.OperaterItem item in m.operateItem)
         {
             GenRpcCode(m, item, ref operationDeclare, ref operationImpl, ref operationImplement, ref num, ref num3, ref rpcValues, ref callBack, ref initController, ref contCallBacks, ref layer, ref layerCtor, ref layerCtoF, ref enterLayer, ref enterFunctions, ref enterFunctionsF, ref callBackARGS, ref testProtocol, ref testArgs, ref str30, ref str31, ref str32);
         }
         testArgs = testArgs + "]\r\n";
         str30    = str30 + "]\r\n";
         str31    = str31 + "]\r\n";
         str32    = str32 + "]\r\n";
         testArgs = testArgs + str30 + str31 + str32;
         num3     = 0;
         foreach (DataStruct struct2 in m.moduleDataStruct)
         {
             if (((struct2.DataType != DataStruct.SyncType.CacheData) && (struct2.DataType != DataStruct.SyncType.ModuleData)) && (struct2.DataType != DataStruct.SyncType.UserData))
             {
                 struct2.StructName.ToLower().IndexOf("rpc");
             }
         }
         updataValue = "";
         foreach (DataStruct struct3 in m.moduleDataStruct)
         {
             if (((struct3.DataType == DataStruct.SyncType.CacheData) || (struct3.DataType == DataStruct.SyncType.ModuleData)) || (struct3.DataType == DataStruct.SyncType.UserData))
             {
                 flag = true;
                 string text2                 = struct3.SaveToDB.ToString();
                 string structName            = struct3.StructName;
                 DataStruct.SyncType dataType = struct3.DataType;
                 DataStruct.SyncType type2    = struct3.DataType;
                 DataStruct.SyncType type3    = struct3.DataType;
                 string text4                 = string.Concat(new object[] { "#include \"", m.ModuleName, "V", m.SyncDataVersion, "Data.h\"\r\n#include \"", m.ModuleName, "V", m.SyncDataVersion, "DataWraper.h\"\r\n" });
                 string text5                 = string.Concat(new object[] { "#include \"", m.ModuleName, "V", m.SyncDataVersion, "DataWraper.h\"\r\n" });
                 string text6                 = struct3.StructName;
                 GenSyncDataCode(m, struct3, ref syncIds, ref syncOpDefine, ref syncOpImp, ref sendAllFields, ref dBCacheField, ref fromMemoryStream, ref updataValue, ref toMemoryStream, ref testArgs, ref getValue, ref rpcValues, ref operationImplement, ref initController);
                 string text7 = string.Concat(new object[] { m.ModuleName, struct3.StructName, "WraperV", m.SyncDataVersion, " m_syncData", struct3.StructName, ";" });
                 string text8 = "SetDataWraper( &m_syncData" + struct3.StructName + " );";
             }
         }
         syncOpDefine = syncOpDefine + sendAllFields + syncOpImp;
         IEnumerator enumerator = DataStructConverter.CommDataStruct.GetEnumerator();
         //using (IEnumerator enumerator = DataStructConverter.CommDataStruct.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 DataStruct current = (DataStruct)enumerator.Current;
             }
         }
         for (int j = 0; j < list3.Count; j++)
         {
             string str33 = (string)list3[j];
             str33    = str33.Replace("$TEMPLATE$", m.ModuleName).Replace("$PBArgs$", rpcValues).Replace("$TempVar$", operationDeclare).Replace("$MoudleVar$", operationImpl).Replace("$PBVar$", operationImplement).Replace("$PBConfig$ ", initController).Replace("$PBVarInit$", fromMemoryStream).Replace("$PBFun$", callBack).Replace("$TempVar2$", syncOpDefine).Replace("$updateWhen$", updataValue).Replace("$SDNotifyF$", contCallBacks).Replace("$CONNOTIFY$", layerCtoF).Replace("$CONNOTIFYFUNCTION$", layerCtor).Replace("$TEST$", testArgs).Replace("$DBCacheField$", dBCacheField);
             list3[j] = str33;
         }
         for (int k = 0; k < list2.Count; k++)
         {
             string str34 = (string)list2[k];
             if ((((str34.IndexOf(string.Concat(new object[] { m.ModuleName, "V", m.SyncDataVersion, "Data" })) <= -1) || flag) && ((str34.IndexOf(m.ModuleName + "DBCache") <= -1) || flag)) && ((str34.IndexOf(string.Concat(new object[] { m.ModuleName, "V", m.SyncDataVersion, "DataWraper" })) <= -1) || flag))
             {
                 StreamWriter writer   = null;
                 UTF8Encoding encoding = new UTF8Encoding(false);
                 writer = new StreamWriter((string)list2[k], false, encoding);
                 writer.Write((string)list3[k]);
                 writer.Close();
             }
         }
     }
 }
Exemplo n.º 14
0
        public static void GenClassWraperCode(Module m, DataStruct ds, ref string strWraper)
        {
            string       str    = "";
            StreamReader reader = new StreamReader("./Template/WraperTemplate.cpp", Encoding.GetEncoding("GBK"));

            str = reader.ReadToEnd();
            reader.Close();
            string str2 = "";

            if (ds.ProtoType == DataStruct.protoTypeE.SyncProto)
            {
                str2 = "V" + m.SyncDataVersion;
            }
            string newValue = ds.getFullName() + "Wraper" + str2;
            string str4     = ds.getFullName() + str2;
            string str5     = "";
            string str6     = "";
            string str7     = "";
            string str8     = "";
            string str9     = "";
            string str10    = "";

            if (((ds.DataType == DataStruct.SyncType.ModuleData) || (ds.DataType == DataStruct.SyncType.CacheData)) || ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient)))
            {
                str9  = ", public ModuleDataInterface , public ModuleDataRegister<" + newValue + ">";
                str10 = "SetDataWraper( this );\r\n";
            }
            foreach (DataStruct.FieldDescriptor descriptor in ds.fieldItem)
            {
                string str11;
                if (descriptor.PreDefine == DataStruct.FieldDescriptor.PreDefineType.optional)
                {
                    str11 = str7;
                    str7  = str11 + "\t\tm_" + descriptor.FieldName + " = v." + descriptor.FieldName.ToLower() + "();\r\n";
                    str8  = str8 + "private:\r\n\t//" + descriptor.CNName + "\r\n";
                    string str12 = str8;
                    str8 = str12 + "\t" + descriptor.ToGetFieldType() + " m_" + descriptor.FieldName + ";\r\npublic:\r\n";
                    if (descriptor.GetTypeEnum() == 1)
                    {
                        string str13 = str6;
                        str6 = str13 + "\t\tv.set_" + descriptor.FieldName.ToLower() + "( m_" + descriptor.FieldName + " );\r\n";
                        string str14 = str8;
                        str8 = str14 + "\tvoid Set" + descriptor.FieldName + "( " + descriptor.ToGetFieldType() + " v)\r\n\t{\r\n\t\tm_" + descriptor.FieldName + "=v;\r\n\t}\r\n";
                        string str15 = str8;
                        str8 = str15 + "\t" + descriptor.ToGetFieldType() + " Get" + descriptor.FieldName + "()\r\n\t{\r\n\t\treturn m_" + descriptor.FieldName + ";\r\n\t}\r\n";
                        string str16 = str5;
                        str5 = str16 + "\t\tm_" + descriptor.FieldName + " = " + descriptor.DefaultValue + ";\r\n";
                    }
                    else if (descriptor.GetTypeEnum() == 2)
                    {
                        string str17 = str6;
                        str6 = str17 + "\t\tv.set_" + descriptor.FieldName.ToLower() + "( m_" + descriptor.FieldName + " );\r\n";
                        string str18 = str8;
                        str8 = str18 + "\tvoid Set" + descriptor.FieldName + "( const " + descriptor.ToGetFieldType() + "& v)\r\n\t{\r\n\t\tm_" + descriptor.FieldName + "=v;\r\n\t}\r\n";
                        string str19 = str8;
                        str8 = str19 + "\t" + descriptor.ToGetFieldType() + " Get" + descriptor.FieldName + "()\r\n\t{\r\n\t\treturn m_" + descriptor.FieldName + ";\r\n\t}\r\n";
                        str5 = str5 + "\t\tm_" + descriptor.FieldName + " = \"\";\r\n";
                    }
                    else
                    {
                        string str20 = str6;
                        str6 = str20 + "\t\t*v.mutable_" + descriptor.FieldName.ToLower() + "()= m_" + descriptor.FieldName + ".ToPB();\r\n";
                        string str21 = str8;
                        str8 = str21 + "\tvoid Set" + descriptor.FieldName + "( const " + descriptor.ToGetFieldType() + "& v)\r\n\t{\r\n\t\tm_" + descriptor.FieldName + "=v;\r\n\t}\r\n";
                        string str22 = str8;
                        str8 = str22 + "\t" + descriptor.ToGetFieldType() + " Get" + descriptor.FieldName + "()\r\n\t{\r\n\t\treturn m_" + descriptor.FieldName + ";\r\n\t}\r\n";
                        string str23 = str5;
                        str5 = str23 + "\t\tm_" + descriptor.FieldName + " = " + descriptor.ToGetFieldType() + "();\r\n";
                    }
                }
                else
                {
                    str7 = str7 + "\t\tm_" + descriptor.FieldName + ".clear();\r\n";
                    string str24 = str7;
                    str7 = str24 + "\t\tm_" + descriptor.FieldName + ".reserve(v." + descriptor.FieldName.ToLower() + "_size());\r\n";
                    str7 = str7 + "\t\tfor( int i=0; i<v." + descriptor.FieldName.ToLower() + "_size(); i++)\r\n";
                    string str25 = str7;
                    str7 = str25 + "\t\t\tm_" + descriptor.FieldName + ".push_back(v." + descriptor.FieldName.ToLower() + "(i));\r\n";
                    str8 = str8 + "private:\r\n\t//" + descriptor.CNName + "\r\n";
                    string str26 = str8;
                    str8 = str26 + "\tvector<" + descriptor.ToGetFieldType() + "> m_" + descriptor.FieldName + ";\r\npublic:\r\n";
                    string str27 = str8;
                    str8 = str27 + "\tint Size" + descriptor.FieldName + "()\r\n\t{\r\n\t\treturn m_" + descriptor.FieldName + ".size();\r\n\t}\r\n";
                    string str28 = str8;
                    str8 = str28 + "\tconst vector<" + descriptor.ToGetFieldType() + ">& Get" + descriptor.FieldName + "() const\r\n\t{\r\n";
                    str8 = str8 + "\t\treturn m_" + descriptor.FieldName + ";\r\n\t}\r\n";
                    string str29 = str8;
                    str8 = str29 + "\t" + descriptor.ToGetFieldType() + " Get" + descriptor.FieldName + "(int Index) const\r\n\t{\r\n";
                    string str30 = str8;
                    str8 = str30 + "\t\tif(Index<0 || Index>=(int)m_" + descriptor.FieldName + ".size())\r\n\t\t{\r\n\t\t\tassert(false);\r\n\t\t\treturn " + descriptor.ToGetFieldType() + "();\r\n\t\t}\r\n";
                    str8 = str8 + "\t\treturn m_" + descriptor.FieldName + "[Index];\r\n\t}\r\n";
                    string str31 = str8;
                    str8 = str31 + "\tvoid Set" + descriptor.FieldName + "( const vector<" + descriptor.ToGetFieldType() + ">& v )\r\n\t{\r\n";
                    str8 = str8 + "\t\tm_" + descriptor.FieldName + "=v;\r\n\t}\r\n";
                    str8 = str8 + "\tvoid Clear" + descriptor.FieldName + "( )\r\n\t{\r\n";
                    str8 = str8 + "\t\tm_" + descriptor.FieldName + ".clear();\r\n\t}\r\n";
                    string str32 = str6;
                    str6 = str32 + "\t\tv.mutable_" + descriptor.FieldName.ToLower() + "()->Reserve(m_" + descriptor.FieldName + ".size());\r\n";
                    if (descriptor.GetTypeEnum() == 1)
                    {
                        string str33 = str8;
                        str8 = str33 + "\tvoid Set" + descriptor.FieldName + "( int Index, " + descriptor.ToGetFieldType() + " v )\r\n\t{\r\n";
                        str8 = str8 + "\t\tif(Index<0 || Index>=(int)m_" + descriptor.FieldName + ".size())\r\n\t\t{\r\n\t\t\tassert(false);\r\n\t\t\treturn;\r\n\t\t}\r\n";
                        str8 = str8 + "\t\tm_" + descriptor.FieldName + "[Index] = v;\r\n\t}\r\n";
                        string str34 = str8;
                        str8  = str34 + "\tvoid Add" + descriptor.FieldName + "( " + descriptor.ToGetFieldType() + " v = " + descriptor.DefaultValue + " )\r\n\t{\r\n";
                        str8  = str8 + "\t\tm_" + descriptor.FieldName + ".push_back(v);\r\n\t}\r\n";
                        str11 = str6;
                        str6  = str11 + "\t\tfor (int i=0; i<(int)m_" + descriptor.FieldName + ".size(); i++)\r\n\t\t{\r\n\t\t\tv.add_" + descriptor.FieldName.ToLower() + "(m_" + descriptor.FieldName + "[i]);\r\n\t\t}\r\n";
                    }
                    else if (descriptor.GetTypeEnum() == 2)
                    {
                        str11 = str8;
                        str8  = str11 + "\tvoid Set" + descriptor.FieldName + "( int Index, const " + descriptor.ToGetFieldType() + "& v )\r\n\t{\r\n";
                        str8  = str8 + "\t\tif(Index<0 || Index>=(int)m_" + descriptor.FieldName + ".size())\r\n\t\t{\r\n\t\t\tassert(false);\r\n\t\t\treturn;\r\n\t\t}\r\n";
                        str8  = str8 + "\t\tm_" + descriptor.FieldName + "[Index] = v;\r\n\t}\r\n";
                        str11 = str8;
                        str8  = str11 + "\tvoid Add" + descriptor.FieldName + "( const " + descriptor.ToGetFieldType() + "& v )\r\n\t{\r\n";
                        str8  = str8 + "\t\tm_" + descriptor.FieldName + ".push_back(v);\r\n\t}\r\n";
                        str11 = str6;
                        str6  = str11 + "\t\tfor (int i=0; i<(int)m_" + descriptor.FieldName + ".size(); i++)\r\n\t\t{\r\n\t\t\tv.add_" + descriptor.FieldName.ToLower() + "( m_" + descriptor.FieldName + "[i]);\r\n\t\t}\r\n";
                    }
                    else
                    {
                        str11 = str8;
                        str8  = str11 + "\tvoid Set" + descriptor.FieldName + "( int Index, const " + descriptor.ToGetFieldType() + "& v )\r\n\t{\r\n";
                        str8  = str8 + "\t\tif(Index<0 || Index>=(int)m_" + descriptor.FieldName + ".size())\r\n\t\t{\r\n\t\t\tassert(false);\r\n\t\t\treturn;\r\n\t\t}\r\n";
                        str8  = str8 + "\t\tm_" + descriptor.FieldName + "[Index] = v;\r\n\t}\r\n";
                        str11 = str8;
                        str8  = str11 + "\tvoid Add" + descriptor.FieldName + "( const " + descriptor.ToGetFieldType() + "& v )\r\n\t{\r\n";
                        str8  = str8 + "\t\tm_" + descriptor.FieldName + ".push_back(v);\r\n\t}\r\n";
                        str11 = str6;
                        str6  = str11 + "\t\tfor (int i=0; i<(int)m_" + descriptor.FieldName + ".size(); i++)\r\n\t\t{\r\n\t\t\t*v.add_" + descriptor.FieldName.ToLower() + "() = m_" + descriptor.FieldName + "[i].ToPB();\r\n\t\t}\r\n";
                    }
                }
            }
            str       = str.Replace("$CNName$", ds.CNName).Replace("$WraperName$", newValue).Replace("$PBName$", str4).Replace("$ConstructField$", str5).Replace("$ToPBField$", str6).Replace("$InitFuncField$", str7).Replace("$GetSetSizeField$", str8).Replace("$ModuleDataWraperDef$", str9).Replace("$ModuleDataSetWraper$", str10);
            strWraper = strWraper + str;
        }
Exemplo n.º 15
0
        private static void GenSyncDataCode(Module m, DataStruct ds, ref string syncIds, ref string SyncOpDefine, ref string SyncOpImp, ref string SendAllFields, ref string DBCacheField, ref string FromMemoryStream, ref string UpdataValue, ref string ToMemoryStream, ref string TestArgs, ref string GetValue, ref string RpcValues, ref string CliOperationImplement, ref string InitController)
        {
            string str   = "V" + m.SyncDataVersion;
            string text1 = ds.StructName + "Wraper" + str;
            string text2 = "SyncData" + m.ModuleName + str;

            if ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
            {
                foreach (DataStruct.FieldDescriptor descriptor in ds.fieldItem)
                {
                    object obj2 = SyncOpDefine;
                    SyncOpDefine = string.Concat(new object[] { obj2, "SYNCID_", descriptor.FieldName.ToUpper(), " = ", (m.StartIdNum * 100) + descriptor.FieldId, "  #", descriptor.CNName, "\r\n" });
                    string str2 = DBCacheField;
                    DBCacheField = str2 + "  SyncID_" + descriptor.FieldName + " : () -> return SYNCID_" + descriptor.FieldName.ToUpper() + "\r\n";
                }
            }
            if (((ds.DataType == DataStruct.SyncType.UserData) || (ds.DataType == DataStruct.SyncType.ItemData)) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
            {
                object obj3 = SyncOpImp;
                SyncOpImp = string.Concat(new object[] { obj3, ds.StructName, "V", m.SyncDataVersion, "PB = null\r\n" });
                object obj4 = CliOperationImplement;
                CliOperationImplement = string.Concat(new object[] { obj4, ds.StructName, "V", m.SyncDataVersion, "PB = null\r\n" });
                object obj5 = InitController;
                InitController = string.Concat(new object[] { obj5, "    ", ds.StructName, "V", m.SyncDataVersion, "PB = Proto.build(\"Rpc", ds.StructName, "V", m.SyncDataVersion, "\")\r\n" });
                DiGui(ref m, ref RpcValues, ds.StructName, true);
            }
            UpdataValue = "";
            foreach (DataStruct.FieldDescriptor descriptor2 in ds.fieldItem)
            {
                if (descriptor2.FieldType == "string")
                {
                    if ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
                    {
                        string str3 = DBCacheField;
                        DBCacheField = str3 + "  " + descriptor2.FieldName + " : () -> return m_" + descriptor2.FieldName + "\r\n";
                        UpdataValue  = UpdataValue + "      when SYNCID_" + descriptor2.FieldName.ToUpper() + "\r\n";
                        if (descriptor2.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated)
                        {
                            SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = []\r\n";
                            UpdataValue   = UpdataValue + "        if Index is -1\r\n";
                            UpdataValue   = UpdataValue + "          m_" + descriptor2.FieldName + " = []\r\n";
                            UpdataValue   = UpdataValue + "          return\r\n";
                            UpdataValue   = UpdataValue + "        if dataLen is 0\r\n";
                            UpdataValue   = UpdataValue + "          return\r\n";
                            UpdataValue   = UpdataValue + "        m_" + descriptor2.FieldName + "[Index] = Data.readUTF8StringBySelf(dataLen)\r\n";
                        }
                        else
                        {
                            SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = \"\"\r\n";
                            UpdataValue   = UpdataValue + "        if dataLen is 0\r\n";
                            UpdataValue   = UpdataValue + "          return\r\n";
                            UpdataValue   = UpdataValue + "        m_" + descriptor2.FieldName + " = Data.readUTF8StringBySelf(dataLen)\r\n";
                        }
                    }
                }
                else if (descriptor2.FieldType == "sint32")
                {
                    if ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
                    {
                        string str4 = DBCacheField;
                        DBCacheField = str4 + "  " + descriptor2.FieldName + " : () -> return m_" + descriptor2.FieldName + "\r\n";
                        UpdataValue  = UpdataValue + "      when SYNCID_" + descriptor2.FieldName.ToUpper() + "\r\n";
                        if (descriptor2.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated)
                        {
                            SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = []\r\n";
                            UpdataValue   = UpdataValue + "        if Index is -1\r\n";
                            UpdataValue   = UpdataValue + "          m_" + descriptor2.FieldName + " = []\r\n";
                            UpdataValue   = UpdataValue + "          return\r\n";
                            UpdataValue   = UpdataValue + "        m_" + descriptor2.FieldName + "[Index] = Data.readVarint32ZigZag()\r\n";
                        }
                        else
                        {
                            SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = 0\r\n";
                            UpdataValue   = UpdataValue + "        m_" + descriptor2.FieldName + " = Data.readVarint32ZigZag()\r\n";
                        }
                    }
                }
                else if (descriptor2.FieldType == "sint64" || descriptor2.FieldType == "uint64")
                {
                    if ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
                    {
                        string str5 = DBCacheField;
                        DBCacheField = str5 + "  " + descriptor2.FieldName + " : () -> return m_" + descriptor2.FieldName + "\r\n";
                        UpdataValue  = UpdataValue + "      when SYNCID_" + descriptor2.FieldName.ToUpper() + "\r\n";
                        if (descriptor2.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated)
                        {
                            SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = []\r\n";
                            UpdataValue   = UpdataValue + "        if Index is -1\r\n";
                            UpdataValue   = UpdataValue + "          m_" + descriptor2.FieldName + " = []\r\n";
                            UpdataValue   = UpdataValue + "          return\r\n";
                            UpdataValue   = UpdataValue + "        m_" + descriptor2.FieldName + "[Index] = Data.readVarint64ZigZag().toNumber()\r\n";
                        }
                        else
                        {
                            SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = 0\r\n";
                            UpdataValue   = UpdataValue + "        m_" + descriptor2.FieldName + " = Data.readVarint64ZigZag().toNumber()\r\n";
                        }
                    }
                }
                else if (descriptor2.PreDefine == DataStruct.FieldDescriptor.PreDefineType.repeated)
                {
                    string str6 = DBCacheField;
                    DBCacheField  = str6 + "  " + descriptor2.FieldName + " : () -> return m_" + descriptor2.FieldName + "\r\n";
                    SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = []\r\n";
                    UpdataValue   = UpdataValue + "      when SYNCID_" + descriptor2.FieldName.ToUpper() + "\r\n";
                    UpdataValue   = UpdataValue + "        if Index is -1\r\n";
                    UpdataValue   = UpdataValue + "          m_" + descriptor2.FieldName + " = []\r\n";
                    UpdataValue   = UpdataValue + "          return\r\n";
                    if (ds.DataType == DataStruct.SyncType.RPCData)
                    {
                        object obj6 = UpdataValue;
                        UpdataValue = string.Concat(new object[] { obj6, "        m_", descriptor2.FieldName, "[Index] = Proto.build(\"Rpc", descriptor2.FieldType, "V", m.SyncDataVersion, "\").decode(Data.toBuffer())\r\n" });
                    }
                    else if ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
                    {
                        string str7 = UpdataValue;
                        UpdataValue = str7 + "        m_" + descriptor2.FieldName + "[Index] = Proto.build(\"" + descriptor2.FieldType + "\").decode(Data.toBuffer())\r\n";
                    }
                }
                else
                {
                    string str8 = DBCacheField;
                    DBCacheField  = str8 + "  " + descriptor2.FieldName + " : () -> return m_" + descriptor2.FieldName + "\r\n";
                    SendAllFields = SendAllFields + "m_" + descriptor2.FieldName + " = null\r\n";
                    UpdataValue   = UpdataValue + "      when SYNCID_" + descriptor2.FieldName.ToUpper() + "\r\n";
                    if (ds.DataType == DataStruct.SyncType.RPCData)
                    {
                        object obj7 = UpdataValue;
                        UpdataValue = string.Concat(new object[] { obj7, "        m_", descriptor2.FieldName, " = Proto.build(\"Rpc", descriptor2.FieldType, "V", m.SyncDataVersion, "\").decode(Data.toBuffer())\r\n" });
                    }
                    else if ((ds.DataType == DataStruct.SyncType.UserData) || ((ds.DataType == DataStruct.SyncType.CacheData) && ds.syncToClient))
                    {
                        string str9 = UpdataValue;
                        UpdataValue = str9 + "        m_" + descriptor2.FieldName + " = Proto.build(\"" + descriptor2.FieldType + "\").decode(Data.toBuffer())\r\n";
                    }
                }
            }
            if ((ds.DataType != DataStruct.SyncType.UserData) && (ds.DataType == DataStruct.SyncType.CacheData))
            {
                bool syncToClient = ds.syncToClient;
            }
            if (UpdataValue.Length > 0)
            {
                UpdataValue = "    switch SyncId\r\n" + UpdataValue;
            }
        }
Exemplo n.º 16
0
        private static void GenRpcCode(Module m, Module.OperaterItem operate, ref string OperationDeclare, ref string OperationImpl, ref string OperationImplement, ref int num, ref int num2, ref string RpcValues, ref string CallBack, ref string InitController, ref string ContCallBacks, ref string Layer, ref string LayerCtor, ref string LayerCtoF, ref string EnterLayer, ref string EnterFunctions, ref string EnterFunctionsF, ref string CallBackARGS, ref string TestProtocol, ref string TestArgs, ref string Test2, ref string Test3, ref string Test4)
        {
            DataStruct struct2 = null;
            DataStruct struct3 = null;
            DataStruct struct4 = null;

            foreach (Module.OperaterItem.SubOperaterItem item in operate.subOperateItem)
            {
                string text1 = operate.Name + item.Name;
                if (item.Type == Module.OperateType.OP_ASK)
                {
                    if (!DataStruct.DataStructDic.TryGetValue(item.DataStructName, out struct2))
                    {
                        DataStruct.DataStructDic.TryGetValue(m.ModuleName + item.DataStructName, out struct2);
                    }
                    struct2.getFullName();
                    if ("      'AskName': [" != TestArgs)
                    {
                        TestArgs = TestArgs + ",\r\n";
                        TestArgs = TestArgs + "                   \"" + operate.Name + "\"";
                    }
                    else
                    {
                        TestArgs = TestArgs + "\"" + operate.Name + "\"";
                    }
                    if ("      'AskList':[" != Test3)
                    {
                        Test3 = Test3 + ",\r\n";
                        Test3 = Test3 + "                 @" + operate.Name;
                    }
                    else
                    {
                        Test3 = Test3 + "@" + operate.Name;
                    }
                    object obj2 = OperationImpl;
                    OperationImpl = string.Concat(new object[] { obj2, "RPC_CODE_", operate.Name.ToUpper(), "_REQUEST = ", (int)num, "\r\n" });
                    num++;
                    OperationImplement = OperationImplement + operate.Name + "AskPB = null\r\n";
                    DiGui(ref m, ref RpcValues, "Rpc" + operate.Name + "Ask", false);
                    string str = "    " + operate.Name + "Ask = " + operate.Name + "AskPB.prototype\r\n";
                    CallBack = CallBack + "  " + operate.Name + " : (";
                    int num3 = 0;
                    if ("      'ParamterTypelist': [" != Test4)
                    {
                        Test4 = Test4 + ",\r\n";
                        Test4 = Test4 + "                       [";
                    }
                    else
                    {
                        Test4 = Test4 + "[";
                    }
                    if ("      'ParamterList': [" != Test2)
                    {
                        Test2 = Test2 + ",\r\n";
                        Test2 = Test2 + "                       [";
                    }
                    else
                    {
                        Test2 = Test2 + "[";
                    }
                    foreach (DataStruct.FieldDescriptor descriptor in struct2.fieldItem)
                    {
                        Test2    = Test2 + ((num3 == 0) ? "" : ",");
                        Test2    = Test2 + "\"" + descriptor.FieldName + "\"";
                        Test4    = Test4 + ((num3 == 0) ? "" : ",");
                        Test4    = Test4 + "\"" + descriptor.FieldType + "\"";
                        CallBack = CallBack + ((num3 == 0) ? "" : ",");
                        CallBack = CallBack + descriptor.FieldName;
                        string str3 = str;
                        str = str3 + "    " + operate.Name + "Ask.set" + descriptor.FieldName + " " + descriptor.FieldName + "\r\n";
                        num3++;
                    }
                    Test2 = Test2 + "]";
                    Test4 = Test4 + "]";
                    string str4 = InitController;
                    InitController = str4 + "    " + operate.Name + "AskPB = Proto.build(\"Rpc" + operate.Name + "Ask\")\r\n";
                    string str5 = str;
                    str = str5 + "    mLayerMgr.sendAsk(RPC_CODE_" + operate.Name.ToUpper() + "_REQUEST," + operate.Name + "Ask, (data)->\r\n";
                    if (operate.Name.ToLower().IndexOf("syncdata") == -1)
                    {
                        str = str + "      NetTipController.hideNetTip()\r\n";
                    }
                    str = (str + "      replyCB( " + operate.Name + "ReplyPB.decode(data)) if typeof(replyCB) is \"function\"\r\n") + "    )\r\n";
                    if (operate.Name.ToLower().IndexOf("syncdata") == -1)
                    {
                        str = str + "    NetTipController.showNetTip()\r\n";
                    }
                    CallBack = CallBack + ((num3 == 0) ? "" : ",");
                    CallBack = CallBack + "replyCB) ->\r\n";
                    CallBack = CallBack + str;
                }
                if (item.Type == Module.OperateType.OP_REPLY)
                {
                    if (!DataStruct.DataStructDic.TryGetValue(item.DataStructName, out struct3))
                    {
                        DataStruct.DataStructDic.TryGetValue(m.ModuleName + item.DataStructName, out struct3);
                    }
                    struct3.getFullName();
                    DiGui(ref m, ref RpcValues, "Rpc" + operate.Name + "Reply", false);
                    OperationImplement = OperationImplement + operate.Name + "ReplyPB = null\r\n";
                    string str6 = InitController;
                    InitController = str6 + "    " + operate.Name + "ReplyPB = Proto.build(\"Rpc" + operate.Name + "Reply\")\r\n";
                }
                if (((item.Type == Module.OperateType.OP_NOTIFY) || (item.Type == Module.OperateType.OP_SERVER_NOTIFY)) || ((item.Type == Module.OperateType.OP_CLIENT_NOTIFY) || (item.Type == Module.OperateType.OP_DUPLEX_NOTIFY)))
                {
                    Module.OperateType type = item.Type;
                    if (!DataStruct.DataStructDic.TryGetValue(item.DataStructName, out struct4))
                    {
                        DataStruct.DataStructDic.TryGetValue(m.ModuleName + item.DataStructName, out struct4);
                    }
                    struct4.getFullName();
                    object obj3 = OperationImpl;
                    OperationImpl = string.Concat(new object[] { obj3, "RPC_CODE_", operate.Name.ToUpper(), "_NOTIFY = ", (int)num, "\r\n" });
                    string str7 = LayerCtoF;
                    LayerCtoF          = str7 + "        _model.Set" + operate.Name + "NotifyCB(@" + operate.Name + "CBNotify)\r\n";
                    LayerCtor          = LayerCtor + "    " + operate.Name + "CBNotify:(ret_msg)->\r\n";
                    LayerCtor          = LayerCtor + "        cc.log \"" + operate.Name + "CBNotify Respond \"\r\n";
                    OperationImplement = OperationImplement + operate.Name + "NotifyPB = null\r\n";
                    DiGui(ref m, ref RpcValues, "Rpc" + operate.Name + "Notify", false);
                    string str8 = InitController;
                    InitController   = str8 + "    " + operate.Name + "NotifyPB = Proto.build(\"Rpc" + operate.Name + "Notify\")\r\n";
                    OperationDeclare = OperationDeclare + item.DataStructName + "CB = null\r\n";
                    if ((item.Type == Module.OperateType.OP_SERVER_NOTIFY) || (item.Type == Module.OperateType.OP_DUPLEX_NOTIFY))
                    {
                        string str9 = InitController;
                        InitController = str9 + "    mLayerMgr.registerNotify(RPC_CODE_" + operate.Name.ToUpper() + "_NOTIFY,@" + operate.Name + "CB)\r\n";
                        string str10 = ContCallBacks;
                        ContCallBacks = str10 + "  Set" + operate.Name + "NotifyCB : (cb) -> " + item.DataStructName + "CB = cb\r\n";
                        ContCallBacks = ContCallBacks + "  " + operate.Name + "CB : (data)->\r\n";
                        string str11 = ContCallBacks;
                        ContCallBacks = str11 + "    " + item.DataStructName + "CB( " + operate.Name + "NotifyPB.decode(data)) if typeof(" + item.DataStructName + "CB) is \"function\"\r\n";
                    }
                    if ((item.Type == Module.OperateType.OP_CLIENT_NOTIFY) || (item.Type == Module.OperateType.OP_DUPLEX_NOTIFY))
                    {
                        if ("      'AskName': [" != TestArgs)
                        {
                            TestArgs = TestArgs + ",\r\n";
                            TestArgs = TestArgs + "                   \"" + operate.Name + "\"";
                        }
                        else
                        {
                            TestArgs = TestArgs + "\"" + operate.Name + "\"";
                        }
                        if ("      'AskList':[" != Test3)
                        {
                            Test3 = Test3 + ",\r\n";
                            Test3 = Test3 + "                 @" + operate.Name;
                        }
                        else
                        {
                            Test3 = Test3 + operate.Name;
                        }
                        string str2 = "    " + operate.Name + "Notify = " + operate.Name + "NotifyPB.prototype\r\n";
                        CallBack = CallBack + "  " + operate.Name + " : (";
                        int num4 = 0;
                        if ("      'ParamterTypelist': [" != Test4)
                        {
                            Test4 = Test4 + ",\r\n";
                            Test4 = Test4 + "                       [";
                        }
                        else
                        {
                            Test4 = Test4 + "[";
                        }
                        if ("      'ParamterList': [" != Test2)
                        {
                            Test2 = Test2 + ",\r\n";
                            Test2 = Test2 + "                       [";
                        }
                        else
                        {
                            Test2 = Test2 + "[";
                        }
                        foreach (DataStruct.FieldDescriptor descriptor2 in struct4.fieldItem)
                        {
                            Test2    = Test2 + ((num4 == 0) ? "" : ",");
                            Test2    = Test2 + "\"" + descriptor2.FieldName + "\"";
                            Test4    = Test4 + ((num4 == 0) ? "" : ",");
                            Test4    = Test4 + "\"" + descriptor2.FieldType + "\"";
                            CallBack = CallBack + ((num4 == 0) ? "" : ",");
                            CallBack = CallBack + descriptor2.FieldName;
                            string str12 = str2;
                            str2 = str12 + "    " + operate.Name + "Notify.set" + descriptor2.FieldName + " " + descriptor2.FieldName + "\r\n";
                            num4++;
                        }
                        Test2    = Test2 + "]";
                        Test4    = Test4 + "]";
                        CallBack = CallBack + ") ->\r\n";
                        string str13 = str2;
                        str2     = str13 + "    mLayerMgr.sendNotify(RPC_CODE_" + operate.Name.ToUpper() + "_NOTIFY," + operate.Name + "Notify)\r\n";
                        CallBack = CallBack + str2;
                    }
                    num++;
                    num2++;
                }
            }
        }