public void GenerateSerializePart(GenSerializeContext context) { _keyBuilder.GenerateSerializePart(context.CreateChild( context.Member .Copy() .AddMember("Key"))); _valueBuilder.GenerateSerializePart(context.CreateChild( context.Member .Copy() .AddMember("Value"))); }
public void GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; var primitive = g.CreateExpression(g.DeclareLocal(_targetType)); GenerateConvert(g, _toPrimitiveMethod, context.Member, primitive); _innerBuilder.GenerateSerializePart(context.CreateChild(primitive)); }
public void GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; g.If(() => { g.Load(context.Member); return(BinaryOperator.IsNull); }); { g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod("WriteVarInt32", typeof(int))); { g.Load(-1); } g.EndCall(); } g.Else(); { g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod("WriteVarInt32", typeof(int))); { g.Load(context.Member); g.BeginCall(_getCount); g.EndCall(); } g.EndCall(); g.Load(context.Member); var item = g.BeginForEach(_elementType); { var innerContext = context.CreateChild(g.CreateExpression(item)); _innerBuilder.GenerateSerializePart(innerContext); } g.EndForEach(); } g.EndIf(); }
void IPartBuilder.GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; g.If(() => { g.Load(context.Member, LoadOptions.ValueAsAddress); g.LoadMember("HasValue"); return(BinaryOperator.IsTrue); }); { g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod(typeof(bool))); { g.Load(true); } g.EndCall(); g.BeginScope(); { _innerBuilder.GenerateSerializePart(context.CreateChild( context.Member .Copy() .AddMember("Value"))); } g.EndScope(); } g.Else(); { g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod(typeof(bool))); { g.Load(false); } g.EndCall(); } g.EndIf(); }
void IPartBuilder.GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; g.If(() => { g.Load(context.Member); return(BinaryOperator.IsNull); }); { g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod("WriteVarInt32", typeof(int))); { g.Load(-1); } g.EndCall(); } g.Else(); { g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod("WriteVarInt32", typeof(int))); { g.Load(context.Member); g.LoadMember("Length"); } g.EndCall(); var i = g.DeclareLocal(typeof(int)); i.Initialize(); g.While(() => { g.Load(i); g.Load(context.Member); g.LoadMember("Length"); return(BinaryOperator.LessThan); }, () => { var element = g.DeclareLocal(_elementType); g.BeginAssign(element); { g.Load(context.Member); g.BeginLoadElement(); { g.Load(i); } g.EndLoadElement(); } g.EndAssign(); var elementContext = context.CreateChild(g.CreateExpression(element)); _elementBuilder.GenerateSerializePart(elementContext); g.BeginAssign(i); { g.Load(i); g.Increment(); } g.EndAssign(); }); } g.EndIf(); }
public void GenerateSerializePart(GenSerializeContext context) { _innerBuilder.GenerateSerializePart(context.CreateChild(context.Member)); }