Пример #1
0
 void Visitor.Visit(TypeDynamic type)
 {
     if (type.IsNeedNegativeCheck)
     {
         sw.WriteLine(prefix + "if (" + varname + ".NegativeCheck()) return true;");
     }
 }
Пример #2
0
 public void Visit(TypeDynamic type)
 {
     // TypeDynamic 使用写好的类 Zeze.Transaction.DynamicBean,
     // 不再需要生成Log。在这里生成 DynamicBean 需要的两个方法。
     sw.WriteLine($"{prefix}public static long GetSpecialTypeIdFromBean_{var.NameUpper1}(Zeze.Transaction.Bean bean)");
     sw.WriteLine($"{prefix}{{");
     sw.WriteLine($"{prefix}    switch (bean.TypeId)");
     sw.WriteLine($"{prefix}    {{");
     sw.WriteLine($"{prefix}        case Zeze.Transaction.EmptyBean.TYPEID: return Zeze.Transaction.EmptyBean.TYPEID;");
     foreach (var real in type.RealBeans)
     {
         sw.WriteLine($"{prefix}        case {real.Value.TypeId}: return {real.Key}; // {real.Value.FullName}");
     }
     sw.WriteLine($"{prefix}    }}");
     sw.WriteLine($"{prefix}    throw new System.Exception(\"Unknown Bean! dynamic@{(var.Bean as Bean).FullName}:{var.Name}\");");
     sw.WriteLine($"{prefix}}}");
     sw.WriteLine();
     sw.WriteLine($"{prefix}public static Zeze.Transaction.Bean CreateBeanFromSpecialTypeId_{var.NameUpper1}(long typeId)");
     sw.WriteLine($"{prefix}{{");
     sw.WriteLine($"{prefix}    switch (typeId)");
     sw.WriteLine($"{prefix}    {{");
     //sw.WriteLine($"{prefix}        case Zeze.Transaction.EmptyBean.TYPEID: return new Zeze.Transaction.EmptyBean();");
     foreach (var real in type.RealBeans)
     {
         sw.WriteLine($"{prefix}        case {real.Key}: return new {real.Value.FullName}();");
     }
     sw.WriteLine($"{prefix}    }}");
     sw.WriteLine($"{prefix}    return null;");
     sw.WriteLine($"{prefix}}}");
     sw.WriteLine();
 }
Пример #3
0
        public void Visit(TypeDynamic type)
        {
            var bean = variable.Bean as Bean;

            sw.WriteLine(prefix + "this." + variable.Name + " = new Zeze.DynamicBean("
                         + $"{bean.Space.Path("_", bean.Name)}.GetSpecialTypeIdFromBean_{variable.NameUpper1}, "
                         + $"{bean.Space.Path("_", bean.Name)}.CreateBeanFromSpecialTypeId_{variable.NameUpper1}"
                         + ");");
        }
Пример #4
0
 public void Visit(TypeDynamic type)
 {
     sw.WriteLine($"{prefix}public {TypeName.GetName(type)}ReadOnly {var.NameUpper1} {{ get; }}");
     sw.WriteLine();
     foreach (Bean real in type.RealBeans.Values)
     {
         string rname = TypeName.GetName(real);
         sw.WriteLine(prefix + "public " + rname + "ReadOnly " + var.NameUpper1 + "_" + real.Space.Path("_", real.Name) + " { get; }");
     }
 }
Пример #5
0
        public void Visit(TypeDynamic type)
        {
            var typeName         = TypeName.GetName(type);
            var beanNameReadOnly = TypeName.GetName(var.Bean) + "ReadOnly";

            sw.WriteLine($"{prefix}public {typeName} {var.NameUpper1} => {var.NamePrivate};");
            sw.WriteLine($"{prefix}{typeName}ReadOnly {beanNameReadOnly}.{var.NameUpper1} => {var.NameUpper1};");

            /*
             * sw.WriteLine(prefix + "{");
             * sw.WriteLine(prefix + "    get");
             * sw.WriteLine(prefix + "    {");
             * sw.WriteLine(prefix + "        if (false == this.IsManaged)");
             * sw.WriteLine(prefix + "            return " + var.NamePrivate + ";");
             * sw.WriteLine(prefix + "        var txn = Zeze.Transaction.Transaction.Current;");
             * sw.WriteLine(prefix + "        if (txn == null) return " + var.NamePrivate + ";");
             * sw.WriteLine(prefix + "        txn.VerifyRecordAccessed(this, true);");
             * sw.WriteLine(prefix + "        var log = (Log_" + var.NamePrivate + ")txn.GetLog(this.ObjectId + " + var.Id + ");");
             * sw.WriteLine(prefix + "        return log != null ? log.Value : " + var.NamePrivate + ";");
             * sw.WriteLine(prefix + "    }");
             * sw.WriteLine(prefix + "    private set");
             * sw.WriteLine(prefix + "    {");
             * sw.WriteLine(prefix + "        if (null == value)");
             * sw.WriteLine(prefix + "            throw new System.ArgumentNullException();");
             * sw.WriteLine(prefix + "        if (false == this.IsManaged)");
             * sw.WriteLine(prefix + "        {");
             * sw.WriteLine(prefix + "            " + var.NamePrivate + " = value;");
             * sw.WriteLine(prefix + "            return;");
             * sw.WriteLine(prefix + "        }");
             * sw.WriteLine(prefix + "        value.InitRootInfo(RootInfo, this);");
             * sw.WriteLine(prefix + "        value.VariableId = " + var.Id + ";");
             * sw.WriteLine(prefix + "        var txn = Zeze.Transaction.Transaction.Current;");
             * sw.WriteLine(prefix + "        txn.VerifyRecordAccessed(this);");
             * sw.WriteLine(prefix + "        txn.PutLog(new Log_" + var.NamePrivate + "(this, value));"); //
             * sw.WriteLine(prefix + "    }");
             * sw.WriteLine(prefix + "}");
             */
            sw.WriteLine();
            foreach (Bean real in type.RealBeans.Values)
            {
                string rname = TypeName.GetName(real);
                string pname = var.NameUpper1 + "_" + real.Space.Path("_", real.Name);
                sw.WriteLine(prefix + "public " + rname + " " + pname);
                sw.WriteLine(prefix + "{");
                sw.WriteLine(prefix + "    get { return (" + rname + ")" + var.NameUpper1 + ".Bean; }");
                sw.WriteLine(prefix + "    set { " + var.NameUpper1 + ".Bean = value; }");
                sw.WriteLine(prefix + "}");
                sw.WriteLine();
                sw.WriteLine(prefix + rname + "ReadOnly " + beanNameReadOnly + "." + pname + " => " + pname + ";");
                sw.WriteLine();
            }
        }
Пример #6
0
        public void Visit(TypeDynamic type)
        {
            if (id >= 0)
            {
                sw.WriteLine($"{prefix}{bufname}.WriteInt(Zeze.ByteBuffer.DYNAMIC | {id} << Zeze.ByteBuffer.TAG_SHIFT);");
                sw.WriteLine($"{prefix}{varname}.Encode({bufname});");

                /*
                 * sw.WriteLine($"{prefix}{bufname}.WriteLong8({varname}.TypeId());");
                 * sw.WriteLine(prefix + "{");
                 * sw.WriteLine(prefix + "    var _state_ = " + bufname + ".BeginWriteSegment();");
                 * sw.WriteLine(prefix + "    " + varname + ".Encode(" + bufname + ");");
                 * sw.WriteLine(prefix + "    " + bufname + ".EndWriteSegment(_state_);");
                 * sw.WriteLine(prefix + "}");
                 */
            }
            else
            {
                throw new Exception("invalie Variable.Id");
            }
        }
Пример #7
0
        void Visitor.Visit(TypeDynamic type)
        {
            if (id >= 0)
            {
                sw.WriteLine(prefix + "case (Zeze.ByteBuffer.DYNAMIC | " + id + " << Zeze.ByteBuffer.TAG_SHIFT): ");
                sw.WriteLine(prefix + $"    {varname}.Decode({bufname});");

                /*
                 * sw.WriteLine(prefix + "    switch (" + bufname + ".ReadLong8())");
                 * sw.WriteLine(prefix + "    {");
                 * foreach (Bean real in type.RealBeans)
                 * {
                 *  string realName = TypeName.GetName(real);
                 *  sw.WriteLine(prefix + "        case " + realName + ".TYPEID:");
                 *  sw.WriteLine(prefix + "            {");
                 *  sw.WriteLine(prefix + "                var _state_ = " + bufname + ".BeginReadSegment();");
                 *  sw.WriteLine(prefix + "                " + varname + " = new " + realName + "();");
                 *  sw.WriteLine(prefix + "                " + varname + ".Decode(" + bufname + ");");
                 *  sw.WriteLine(prefix + "                " + bufname + ".EndReadSegment(_state_);");
                 *  sw.WriteLine(prefix + "            }");
                 *  sw.WriteLine(prefix + "            break;");
                 * }
                 * sw.WriteLine(prefix + "        case Zeze.EmptyBean.TYPEID:");
                 * sw.WriteLine(prefix + "            " + varname + " = new Zeze.EmptyBean();");
                 * sw.WriteLine(prefix + "            " + bufname + ".SkipBytes();");
                 * sw.WriteLine(prefix + "            break;");
                 * sw.WriteLine(prefix + "        default:");
                 * sw.WriteLine(prefix + "            " + bufname + ".SkipBytes();");
                 * sw.WriteLine(prefix + "            break;");
                 * sw.WriteLine(prefix + "    }");
                 */
                sw.WriteLine(prefix + "    break;");
            }
            else
            {
                throw new Exception("invalie Variable.Id");
            }
        }
Пример #8
0
 void Visitor.Visit(TypeDynamic type)
 {
     throw new NotImplementedException();
 }
Пример #9
0
 void Visitor.Visit(TypeDynamic type)
 {
     Type = Zeze.Serialize.ByteBuffer.DYNAMIC;
     // TypeBeanTypeId = 使用的时候指定。
 }
Пример #10
0
 void Visitor.Visit(TypeDynamic type)
 {
     ChangeVariableCollectorName = "Zeze.Transaction.ChangeVariableCollectorChanged()";
 }
Пример #11
0
 void Visitor.Visit(TypeDynamic type)
 {
     Name = "Zeze.ByteBuffer.DYNAMIC";
 }
Пример #12
0
 public void Visit(TypeDynamic type)
 {
     name = "Zeze.Transaction.DynamicBean";
 }
Пример #13
0
 void Visitor.Visit(TypeDynamic type)
 {
     Value = "null";
 }
Пример #14
0
 public void Visit(TypeDynamic type)
 {
     DefineStack(type);
 }
Пример #15
0
 public void Visit(TypeDynamic type)
 {
     name = "Zeze.DynamicBean";
 }
Пример #16
0
 public void Visit(TypeDynamic type)
 {
     sw.WriteLine(prefix + variable.NamePrivate + " = new Zeze.Transaction.DynamicBean"
                  + $"({variable.Id}, GetSpecialTypeIdFromBean_{variable.NameUpper1}, CreateBeanFromSpecialTypeId_{variable.NameUpper1});");
 }
Пример #17
0
 void Visitor.Visit(TypeDynamic type)
 {
     sw.WriteLine(prefix + $"sb.Append(new string(' ', level * 4)).Append(\"{var}\").Append(\"=\").Append(Environment.NewLine);");
     sw.WriteLine(prefix + var + ".Bean.BuildString(sb, level + 1);");
     sw.WriteLine(prefix + $"sb.Append(\"{sep}\").Append(Environment.NewLine);");
 }