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.BeginCall(_writeMethod); { g.Load(context.Writer); g.Load(context.Member); } g.EndCall(); }
public void GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; g.Load(context.Writer); g.BeginCall(MemberResolver.GetWriteMethod(_writeMethodName, Type)); { g.Load(context.Member); } g.EndCall(); }
public void GenerateSerializePart(GenSerializeContext context) { _keyBuilder.GenerateSerializePart(context.CreateChild( context.Member .Copy() .AddMember("Key"))); _valueBuilder.GenerateSerializePart(context.CreateChild( context.Member .Copy() .AddMember("Value"))); }
void IPartBuilder.GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; g.Load(context.Writer); g.LoadMember("BaseStream"); g.BeginCall(typeof(Stream).GetMethod("Write", new[] { typeof(byte[]), typeof(int), typeof(int) })); { g.Load(context.Member, LoadOptions.ValueAsAddress); g.BeginCall(typeof(Guid).GetMethod("ToByteArray", Type.EmptyTypes)); g.EndCall(); // , g.Load(0); // , g.Load(_guidSize); } g.EndCall(); }
public void GenerateSerializePart(GenSerializeContext context) { var g = context.Generator; g.Load(context.SerializationArgs); g.LoadMember("BinaryFormatter"); g.BeginCall(typeof(BinaryFormatter).ResolveMethod("Serialize", typeof(Stream), typeof(object))); { g.Load(context.Writer); g.LoadMember("BaseStream"); g.Load(context.Member); if (context.Member.Type.IsValueType) { g.Box(); } } g.EndCall(); }
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)); }