public object Execute( DeserializationContext context ) { var instance = context.CreatedObjects.Get( this._instanceId ); var parameters = this._parameters.Select( par => par.Execute( context ) ).ToArray(); return this._method.Invoke( instance, parameters ); }
public object Execute( DeserializationContext context ) { object result = context.GetById( this._ownerId ); var reversePath = this._path.Reverse().ToArray(); result = reversePath.Take( this._path.Length - 1 ).Aggregate( result, ( current, memberInfo ) => this.GetValue( memberInfo, current ) ); this.SetValue( reversePath.Last(), result, this._value ); return null; }
public object Execute( DeserializationContext context ) { object owner = context.GetById( this._ownerId ); foreach ( var memberInfo in this._propertiesPath.Reverse() ) { if ( memberInfo is PropertyInfo ) { owner = ( ( PropertyInfo ) memberInfo ).GetValue( owner, null ); } else if ( memberInfo is FieldInfo ) { owner = ( ( FieldInfo ) memberInfo ).GetValue( owner ); } else { throw new InvalidOperationException(); } } var parameters = this._parameters.Select( s => s.Execute( context ) ).ToArray(); return this._methodInfo.Invoke( owner, parameters ); }