Esempio n. 1
0
		protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, 
		                                               ArgumentReference arg1, ArgumentReference arg2)
		{
			Type[] key_and_object = new Type[] {typeof (String), typeof (Object)};
			Type[] key_and_bool = new Type[] {typeof (String), typeof (bool)};
			MethodInfo addValueMethod = typeof (SerializationInfo).GetMethod("AddValue", key_and_object);
			MethodInfo addValueBoolMethod = typeof (SerializationInfo).GetMethod("AddValue", key_and_bool);

			codebuilder.AddStatement( new ExpressionStatement(
				new VirtualMethodInvocationExpression(arg1, addValueBoolMethod, 
				new FixedReference("__delegateToBase").ToExpression(), 
				new FixedReference( _delegateToBaseGetObjectData ? 1 : 0 ).ToExpression() ) ) );

			if (_delegateToBaseGetObjectData)
			{
				MethodInfo baseGetObjectData = _baseType.GetMethod("GetObjectData", 
					new Type[] { typeof(SerializationInfo), typeof(StreamingContext) });

				codebuilder.AddStatement( new ExpressionStatement(
					new MethodInvocationExpression( baseGetObjectData, 
						arg1.ToExpression(), arg2.ToExpression() )) );
			}
			else
			{
				LocalReference members_ref = codebuilder.DeclareLocal( typeof(MemberInfo[]) );
				LocalReference data_ref = codebuilder.DeclareLocal( typeof(object[]) );

				MethodInfo getSerMembers = typeof(FormatterServices).GetMethod("GetSerializableMembers", 
					new Type[] { typeof(Type) });
				MethodInfo getObjData = typeof(FormatterServices).GetMethod("GetObjectData", 
					new Type[] { typeof(object), typeof(MemberInfo[]) });
				
				codebuilder.AddStatement( new AssignStatement( members_ref,
					new MethodInvocationExpression( null, getSerMembers, 
					new TypeTokenExpression( _baseType ) )) );
				
				codebuilder.AddStatement( new AssignStatement( data_ref, 
					new MethodInvocationExpression( null, getObjData, 
					SelfReference.Self.ToExpression(), members_ref.ToExpression() )) );

				codebuilder.AddStatement( new ExpressionStatement(
					new VirtualMethodInvocationExpression(arg1, addValueMethod, 
					new FixedReference("__data").ToExpression(), 
					data_ref.ToExpression() ) ) );
			}
		}
Esempio n. 2
0
 protected virtual void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference arg1,
     ArgumentReference arg2)
 {
 }
Esempio n. 3
0
        public void WriteInitialization(AbstractCodeBuilder codebuilder,
            Reference targetArgument, Reference mixinArray)
        {
            NewInstanceExpression newInst = null;

            if (SourceArgIndex == EmptyIndex)
            {
                newInst = new NewInstanceExpression(Callable,
                                                    targetArgument.ToExpression(), new MethodPointerExpression(_callback));
            }
            else
            {
                newInst = new NewInstanceExpression(Callable,
                                                    new LoadRefArrayElementExpression(SourceArgIndex, mixinArray),
                                                    new MethodPointerExpression(_callback));
            }

            codebuilder.AddStatement(new AssignStatement(
                                     	Field, newInst));
        }
		protected override void CustomizeGetObjectData(AbstractCodeBuilder codebuilder, ArgumentReference arg1,
		                                               ArgumentReference arg2)
		{
			Type[] key_and_object = new Type[] {typeof(String), typeof(Object)};
			MethodInfo addValueMethod = typeof(SerializationInfo).GetMethod("AddValue", key_and_object);

			codebuilder.AddStatement(new ExpressionStatement(
			                         	new VirtualMethodInvocationExpression(arg1, addValueMethod,
			                         	                                      new FixedReference("__target").ToExpression(),
			                         	                                      _targetField.ToExpression())));
		}