public PropertyReflector <TInstance, TProperty> GetProperty <TProperty>(Expression <Func <TInstance, TProperty> > propertyExpression) { TInstance instance = (TInstance)InstanceGetter.GetInstance(); var finder = new ExpressionPropertyFinder <TInstance, TProperty>(propertyExpression); return(new PropertyReflector <TInstance, TProperty>(instance, finder)); }
internal object CreateInstanceCore(object[] ctorArgs) { Contracts.Assert(Utils.Size(ctorArgs) == CtorTypes.Length + ((RequireEnvironment) ? 1 : 0)); try { if (InstanceGetter != null) { Contracts.Assert(Utils.Size(ctorArgs) == 0); return(InstanceGetter.Invoke(null, null)); } if (Constructor != null) { return(Constructor.Invoke(ctorArgs)); } if (CreateMethod != null) { return(CreateMethod.Invoke(null, ctorArgs)); } } catch (TargetInvocationException ex) { if (ex.InnerException != null && ex.InnerException.IsMarked()) { throw Contracts.Except(ex, "Error during class instantiation"); } else { throw; } } throw Contracts.Except("Can't instantiate class '{0}'", Type.Name); }
public WeakMethodReflector <TInstance, TReturn> GetMethod <TReturn>(Expression <Func <TInstance, TReturn> > expression) { TInstance instance = (TInstance)InstanceGetter.GetInstance(); var finder = new ExpressionMethodFinder <TInstance, TReturn>(expression); return(new WeakMethodReflector <TInstance, TReturn>(instance, finder)); }
internal object CreateInstanceCore(object[] ctorArgs) { Contracts.Assert(Utils.Size(ctorArgs) == CtorTypes.Length + ((RequireEnvironment) ? 1 : 0)); if (InstanceGetter != null) { Contracts.Assert(Utils.Size(ctorArgs) == 0); return(InstanceGetter.Invoke(null, null)); } if (Constructor != null) { return(Constructor.Invoke(ctorArgs)); } if (CreateMethod != null) { return(CreateMethod.Invoke(null, ctorArgs)); } throw Contracts.Except("Can't instantiate class '{0}'", Type.Name); }