/// <summary>
		///		Initializes a new instance of the <see cref="DynamicMethodEmittingContext"/> class.
		/// </summary>
		/// <param name="context">The serialization context.</param>
		/// <param name="targetType">Type of the serialization target.</param>
		/// <param name="emitterFactory">
		///		The factory for <see cref="SerializerEmitter"/> to be used.
		/// </param>
		/// <param name="enumEmitterFactory">
		///		The factory for <see cref="EnumSerializerEmitter"/> to be used.
		/// </param>
		public DynamicMethodEmittingContext( SerializationContext context, Type targetType,
			Func<SerializerEmitter> emitterFactory, Func<EnumSerializerEmitter> enumEmitterFactory )
			: base( context, emitterFactory, enumEmitterFactory )
		{
			this._context = ILConstruct.Argument( 0, typeof( SerializationContext ), "context" );
			this.Reset( targetType, null );
		}
Exemplo n.º 2
0
		public StoreFieldILConstruct( ILConstruct instance, FieldInfo field, ILConstruct value )
			: base( typeof( void ) )
		{
			this._instance = instance;
			this._field = field;
			this._value = value;
		}
Exemplo n.º 3
0
		public InvocationILConsruct( MethodInfo method, Type @interface, ILConstruct target, IEnumerable<ILConstruct> arguments )
			: base( method.ReturnType )
		{
			if ( method.IsStatic )
			{
				if ( target != null )
				{
					throw new ArgumentException(
						String.Format( CultureInfo.CurrentCulture, "target must be null for static method '{0}'", method )
					);
				}
			}
			else
			{
				if ( target == null )
				{
					throw new ArgumentException(
						String.Format( CultureInfo.CurrentCulture, "target must not be null for instance method '{0}'", method )
					);
				}
			}

			this._method = method;
			this._target = target;
			this._arguments = arguments;
			this._interface = @interface;
		}
Exemplo n.º 4
0
		public StoreFieldILConstruct( ILConstruct instance, FieldInfo field, ILConstruct value )
			: base( TypeDefinition.VoidType )
		{
			this._instance = instance;
			this._field = field;
			this._value = value;
		}
Exemplo n.º 5
0
		public UnaryOperatorILConstruct( string @operator, ILConstruct input, Action<TracingILGenerator, ILConstruct> operation, Action<TracingILGenerator, ILConstruct, Label> branchOperation )
			: base( input.ContextType )
		{
			this._operator = @operator;
			this._input = input;
			this._operation = operation;
			this._branchOperation = branchOperation;
		}
Exemplo n.º 6
0
		public BinaryOperatorILConstruct( string @operator, Type resultType, ILConstruct left, ILConstruct right, Action<TracingILGenerator, ILConstruct, ILConstruct> operation, Action<TracingILGenerator, ILConstruct, ILConstruct, Label> branchOperation )
			: base( resultType )
		{
			ValidateContextTypeMatch( left, right );
			this._operator = @operator;
			this._left = left;
			this._right = right;
			this._operation = operation;
			this._branchOperation = branchOperation;
		}
Exemplo n.º 7
0
		public ConditionalILConstruct( ILConstruct condition, ILConstruct thenExpression, ILConstruct elseExpression )
			: base( thenExpression.ContextType )
		{
			if ( condition.ContextType.ResolveRuntimeType() != typeof( bool ) )
			{
				throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, "condition must be boolean: {0}", condition ), "condition" );
			}

			if ( elseExpression != null && elseExpression.ContextType.ResolveRuntimeType() != thenExpression.ContextType.ResolveRuntimeType() )
			{
				throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, "elseExpression type must be '{0}' but '{1}':{2}", thenExpression.ContextType, elseExpression.ContextType, elseExpression ), "elseExpression" );
			}

			this._condition = condition;
			this._thenExpression = thenExpression;
			this._elseExpression = elseExpression;
		}
Exemplo n.º 8
0
		public InvocationILConsruct( ConstructorInfo ctor, ILConstruct target, IEnumerable<ILConstruct> arguments )
			: base( ctor.DeclaringType )
		{
			if ( ctor.DeclaringType.GetIsValueType() )
			{
				if ( target == null )
				{
					throw new ArgumentException(
						String.Format( CultureInfo.CurrentCulture, "target must not be null for expression type constructor '{0}'", ctor )
					);
				}
			}

			this._method = ctor;
			this._target = target;
			this._arguments = arguments;
		}
		public StatementExpressionILConstruct( ILConstruct binding, ILConstruct expression )
			: base( expression.ContextType )
		{
			this._binding = binding;
			this._expression = expression;
		}
Exemplo n.º 10
0
		public LoadFieldILConstruct( ILConstruct instance, FieldInfo field )
			: base( field.FieldType )
		{
			this._instance = instance;
			this._field = field;
		}
Exemplo n.º 11
0
		private static void BranchWithOperationResult( ILConstruct input, Action<TracingILGenerator, ILConstruct> operation, TracingILGenerator il, Label @else )
		{
			operation( il, input );
			il.EmitBrfalse( @else );
		}
Exemplo n.º 12
0
		public UnaryOperatorILConstruct( string @operator, ILConstruct input, Action<TracingILGenerator, ILConstruct> operation )
			: this( @operator, input, operation, ( il, i, @else ) => BranchWithOperationResult( i, operation, il, @else ) )
		{
		}
Exemplo n.º 13
0
		public StoreVariableILConstruct( ILConstruct variable, ILConstruct value )
			: base( typeof( void ) )
		{
			this._variable = variable;
			this._value = value;
		}
Exemplo n.º 14
0
		public StoreVariableILConstruct( ILConstruct variable, ILConstruct value )
			: base( TypeDefinition.VoidType )
		{
			this._variable = variable;
			this._value = value;
		}