Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
            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);
            }