protected virtual void Dispose( bool disposing ) { DEBUG.IndentLine( "\n-- DynamicParser.Dispose( Disposing={0} ) This={1}", disposing, this ); _Returned = null; // It might be in use elsewhere... if( _LastNode != null ) { _LastNode.Dispose(); _LastNode = null; } if( _Arguments != null ) { foreach( var arg in _Arguments ) arg.Dispose(); _Arguments.Clear(); _Arguments = null; } DEBUG.Unindent(); }
protected Convert( SerializationInfo info, StreamingContext context ) : base( info, context ) { TargetType = (Type)info.GetValue( "TargetType", typeof( Type ) ); string type = info.GetString( "SourceType" ); SourceNode = (DynamicNode)info.GetValue( "SourceItem", Type.GetType( type ) ); }
/// <summary> /// Creates a new instance of <see cref="DynamicNode.Convert"/> for the target node to the target type. /// </summary> /// <param name="targetType">The target type to convert the target node to.</param> /// <param name="sourceNode">The target node.</param> public Convert( Type targetType, DynamicNode sourceNode ) { DEBUG.IndentLine( "\n-- Convert( Type={0}, Source={1} )", targetType.Name, TypeHelper.ToString( sourceNode ) ); TargetType = targetType; if( ( SourceNode = sourceNode ) == null ) throw new ArgumentNullException( "source", "Source cannot be null." ); DEBUG.Unindent(); }
protected Unary( SerializationInfo info, StreamingContext context ) : base( info, context ) { Operation = (ExpressionType)info.GetValue( "Operation", typeof( ExpressionType ) ); string type = info.GetString( "TargetType" ); Target = (DynamicNode)info.GetValue( "TargetItem", Type.GetType( type ) ); }
/// <summary> /// Creates a new <see cref="DynamicNode.Unary"/> instance for its target operand. /// </summary> /// <param name="operation">The unary operation to (conceptually) execute.</param> /// <param name="target">The target operand for this operation.</param> public Unary( ExpressionType operation, DynamicNode target ) { DEBUG.IndentLine( "\n-- Unary( Operation={0}, Target={1} )", operation, TypeHelper.ToString( target ) ); Operation = operation; if( ( Target = target ) == null ) throw new ArgumentNullException( "target", "Target cannot be null." ); DEBUG.Unindent(); }
/// <summary> /// Creates a new <see cref="DynamicNode.Binary"/> instance for the operands given. /// </summary> /// <param name="left">The <see cref="DynamicNode"/> left operand who has (conceptually) initiate this operation.</param> /// <param name="operation">The operation to (conceptually) execute.</param> /// <param name="right">The right operand of the expression, that can be any valid object including null references.</param> public Binary( DynamicNode left, ExpressionType operation, object right ) { DEBUG.IndentLine( "\n-- Binary( Left={0}, Operation={1}, Right={2} )", TypeHelper.ToString( left ), operation, TypeHelper.ToString( right ) ); if( ( Left = left ) == null ) throw new ArgumentNullException( "left", "Left cannot be null." ); Operation = operation; Right = right; DEBUG.Unindent(); }
/// <summary> /// Creates a new instance of <see cref="DynamicNode.Invoke"/> for the node specified using the arguments given. /// </summary> /// <param name="host">The node to (conceptually) invoke.</param> /// <param name="arguments">The arguments to use to invoke this node. It can be null if no arguments are used.</param> public Invoke( DynamicNode host, object[] arguments ) { DEBUG.IndentLine( "\n-- Invoke( Host={0}, Arguments={1} )", TypeHelper.ToString( host ), TypeHelper.ToString( arguments, brackets: "()" ) ); if( ( _Host = host ) == null ) throw new ArgumentNullException( "host", "Host cannot be null." ); Arguments = arguments == null ? new object[0] : arguments; DEBUG.Unindent(); }
/// <summary> /// Create a new instance of <see cref="DynamicNode.Method"/> hosted in the given parent and with the arguments /// given. /// </summary> /// <param name="host">The hosting parent of this node.</param> /// <param name="name">The name of the method to (conceptually) invoke.</param> /// <param name="arguments">The arguments to use with the method. It can be null if no arguments are used.</param> public Method( DynamicNode host, string name, object[] arguments ) { DEBUG.IndentLine( "\n-- Method( Host={0}, Name={1}, Arguments={2} )", TypeHelper.ToString( host ), name ?? "null", TypeHelper.ToString( arguments, brackets: "()" ) ); if( ( _Host = host ) == null ) throw new ArgumentNullException( "host", "Host cannot be null." ); Name = name.Validated( "Name", invalidChars: TypeHelper.InvalidNameChars ); Arguments = arguments == null ? new object[0] : arguments; DEBUG.Unindent(); }
/// <summary> /// Create a new instance of <see cref="DynamicNode.GetIndex"/> hosted in the given parent and with the indexes /// given. /// </summary> /// <param name="host">The hosting parent of this node.</param> /// <param name="indexes">The indexes used to access this member.</param> /// /// <param name="value">The value to (logically) set to this member.</param> public SetIndex( DynamicNode host, object[] indexes, object value ) { DEBUG.IndentLine( "\n-- SetIndex( Host={0}, Indexes={1}, Value={2} )", TypeHelper.ToString( host ), TypeHelper.ToString( indexes, brackets: "[]" ), TypeHelper.ToString( value ) ); if( ( _Host = host ) == null ) throw new ArgumentNullException( "host", "Host cannot be null." ); Indexes = indexes == null ? new object[0] : indexes; Value = value; DEBUG.Unindent(); }
/// <summary> /// Creates a new <see cref="DynamicNode.SetMember"/> instance for a member hosted in the given parent, with the /// name given, and specifying the value to (logically) set to it. /// </summary> /// <param name="host">The hosting parent of this node.</param> /// <param name="name">The name of the member to set its value.</param> /// <param name="value">The value to (logically) set to this member.</param> public SetMember( DynamicNode host, string name, object value ) { DEBUG.IndentLine( "\n-- SetMember( Host={0}, Name={1}, Value={2} )", TypeHelper.ToString( host ), name ?? "null", TypeHelper.ToString( value ) ); if( ( _Host = host ) == null ) throw new ArgumentNullException( "host", "Host cannot be null." ); Name = name.Validated( "Name", invalidChars: TypeHelper.InvalidNameChars ); Value = value; DEBUG.Unindent(); }
protected DynamicNode( SerializationInfo info, StreamingContext context ) { string type = info.GetString( "HostType" ); _Host = type == "VOID" ? null : (DynamicNode)info.GetValue( "HostItem", Type.GetType( type ) ); }
protected virtual void Dispose( bool disposing ) { DEBUG.IndentLine( "\n-- DynamicNode.Dispose( Disposing={0} ) - This={1}", disposing, this ); _Host = null; _Parser = null; DEBUG.Unindent(); }