Beispiel #1
0
        public static void GenerateCode3()
        {
            ProtoGenerator textClass = new ProtoGenerator("TestClass");

            textClass.SetNamespace("MM");
            textClass.AddProperty("id", "int");
            textClass.AddProperty("id1", "int");
            string classValue = textClass.ToString();

            TxtUtility.StringToFile(classValue);
            //Debug.Log(classValue);
        }
Beispiel #2
0
        public ClassData ToProtoClass()
        {
            ClassData data = new ClassData();

            data.className = sheetName;
            ProtoGenerator generator = new ProtoGenerator(sheetName);

            for (int i = 0; i < memberNames.Length; i++)
            {
                Type filterType = GetFilterType(fieldTypes[i]);
                generator.AddProperty(memberNames[i], fieldTypes[i]);
                if (filterType != null)
                {
                    MethodInfo usingMethod = filterType.GetMethod("GetUsings");
                    if (usingMethod == null)
                    {
                        continue;
                    }
                    object   filterObj  = Activator.CreateInstance(filterType);
                    string[] usingNames = usingMethod.Invoke(filterObj, null) as string[];
                    if (usingNames == null)
                    {
                        continue;
                    }
                    foreach (string name in usingNames)
                    {
                        generator.AddUsingName(name);
                    }
                }
            }
            data.classContent = generator.ToString();
            return(data);
        }