Beispiel #1
0
 public void Make(System.IO.StreamWriter sw)
 {
     sw.WriteLine("export class " + bean.Space.Path("_", bean.Name) + " implements Zeze.Bean {");
     // declare enums
     foreach (Types.Enum e in bean.Enums)
     {
         sw.WriteLine("    public static readonly " + e.Name + " = " + e.Value + ";" + e.Comment);
     }
     if (bean.Enums.Count > 0)
     {
         sw.WriteLine("");
     }
     // declare variables
     foreach (Types.Variable v in bean.Variables)
     {
         sw.WriteLine($"    public {v.Name}: {TypeName.GetName(v.VariableType)}; {v.Comment}");
     }
     sw.WriteLine("");
     sw.WriteLine();
     Construct.Make(bean, sw, "    ");
     sw.WriteLine();
     sw.WriteLine("    public static readonly TYPEID: bigint = " + bean.TypeId + "n;");
     sw.WriteLine("    public TypeId(): bigint { return " + bean.Space.Path("_", bean.Name) + ".TYPEID; }");
     sw.WriteLine();
     Encode.Make(bean, sw, "    ");
     Decode.Make(bean, sw, "    ");
     MakeDynamicStaticFunc(sw);
     sw.WriteLine("}");
     sw.WriteLine();
 }
Beispiel #2
0
        public void Make(System.IO.StreamWriter sw)
        {
            sw.WriteLine("export class " + beanKey.Space.Path("_", beanKey.Name) + " implements Zeze.Bean {");
            // declare enums
            foreach (Types.Enum e in beanKey.Enums)
            {
                sw.WriteLine("    public static readonly " + e.Name + " = " + e.Value + ";" + e.Comment);
            }
            if (beanKey.Enums.Count > 0)
            {
                sw.WriteLine("");
            }

            // declare variables
            foreach (Types.Variable v in beanKey.Variables)
            {
                sw.WriteLine($"    public {v.Name}: {TypeName.GetName(v.VariableType)}; {v.Comment}");
            }
            sw.WriteLine("");

            // params construct with init
            {
                sw.WriteLine("     public constructor(" + GetParamListWithDefault(beanKey.Variables) + ") {");
                foreach (Types.Variable v in beanKey.Variables)
                {
                    sw.WriteLine("        this." + v.Name + " = " + v.NamePrivate + "_;");
                }
                sw.WriteLine("    }");
                sw.WriteLine("");
            }
            sw.WriteLine("    public static readonly TYPEID: bigint = " + beanKey.TypeId + "n;");
            sw.WriteLine("    public TypeId(): bigint { return " + beanKey.Space.Path("_", beanKey.Name) + ".TYPEID; }");
            sw.WriteLine();
            sw.WriteLine("");
            Encode.Make(beanKey, sw, "    ");
            Decode.Make(beanKey, sw, "    ");
            sw.WriteLine("}");
        }