protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference arg1, ArgumentReference arg2) { Type[] types = new Type[] { typeof(string), typeof(object) }; MethodInfo method = typeof(SerializationInfo).GetMethod("AddValue", types); codebuilder.AddStatement(new ExpressionStatement(new VirtualMethodInvocationExpression(arg1, method, new Expression[] { new FixedReference("__target").ToExpression(), this._targetField.ToExpression() }))); }
public void WriteInitialization(AbstractCodeBuilder codebuilder, Reference targetArgument, Reference mixinArray) { NewInstanceExpression expression = null; if (this.SourceArgIndex == EmptyIndex) { expression = new NewInstanceExpression(this.Callable, new Expression[] { targetArgument.ToExpression(), new MethodPointerExpression(this._callback) }); } else { expression = new NewInstanceExpression(this.Callable, new Expression[] { new LoadRefArrayElementExpression(this.SourceArgIndex, mixinArray), new MethodPointerExpression(this._callback) }); } codebuilder.AddStatement(new AssignStatement(this.Field, expression)); }
/// <summary> /// /// </summary> /// <param name="codebuilder"></param> /// <param name="arg1"></param> /// <param name="arg2"></param> protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference arg1, ArgumentReference arg2) { Type[] types = new Type[] { typeof(string), typeof(object) }; Type[] typeArray2 = new Type[] { typeof(string), typeof(bool) }; MethodInfo method = typeof(SerializationInfo).GetMethod("AddValue", types); MethodInfo info2 = typeof(SerializationInfo).GetMethod("AddValue", typeArray2); codebuilder.AddStatement(new ExpressionStatement(new VirtualMethodInvocationExpression(arg1, info2, new Expression[] { new FixedReference("__delegateToBase").ToExpression(), new FixedReference(this._delegateToBaseGetObjectData ? 1 : 0).ToExpression() }))); if (this._delegateToBaseGetObjectData) { MethodInfo info3 = base._baseType.GetMethod("GetObjectData", new Type[] { typeof(SerializationInfo), typeof(StreamingContext) }); codebuilder.AddStatement(new ExpressionStatement(new MethodInvocationExpression(info3, new Expression[] { arg1.ToExpression(), arg2.ToExpression() }))); } else { LocalReference target = codebuilder.DeclareLocal(typeof(MemberInfo[])); LocalReference reference2 = codebuilder.DeclareLocal(typeof(object[])); MethodInfo info4 = typeof(FormatterServices).GetMethod("GetSerializableMembers", new Type[] { typeof(Type) }); MethodInfo info5 = typeof(FormatterServices).GetMethod("GetObjectData", new Type[] { typeof(object), typeof(MemberInfo[]) }); codebuilder.AddStatement(new AssignStatement(target, new MethodInvocationExpression(null, info4, new Expression[] { new TypeTokenExpression(base._baseType) }))); codebuilder.AddStatement(new AssignStatement(reference2, new MethodInvocationExpression(null, info5, new Expression[] { SelfReference.Self.ToExpression(), target.ToExpression() }))); codebuilder.AddStatement(new ExpressionStatement(new VirtualMethodInvocationExpression(arg1, method, new Expression[] { new FixedReference("__data").ToExpression(), reference2.ToExpression() }))); } }