예제 #1
0
        public static IConstantExpressionWithReflection CreateExpression(object value)
        {
            if (value == null)
            {
                return(new NullExpressionWithReflection());
            }

            Type type = value as Type;

            if (type != null)
            {
                return(new TypeofExpressionWithReflection(TypeReferenceWithReflectionFactory.CreateReference(type)));
            }

            switch (Type.GetTypeCode(value.GetType()))
            {
            case TypeCode.Double:
                return(new DoubleConstantExpressionWithReflection((double)value));

            case TypeCode.Int32:
                return(new IntegerConstantExpressionWithReflection((int)value));

            case TypeCode.String:
                return(new StringConstantExpressionWithReflection((string)value));

            default:
                throw new NotImplementedException();
            }
        }
        private static bool InitializeReflection(ReadOnlyTypeReference type)
        {
            if (type.type.Type == null)
            {
                return(false);
            }

            type.typeReferenceWithReflection = TypeReferenceWithReflectionFactory.CreateReference(type.type.Type);
            type.typeReferenceType           = reflectionType;
            type.name = type.typeReferenceWithReflection.Type.Name;
            return(true);
        }
예제 #3
0
 internal MethodWithReflection(ITypeWithReflection declaringType, MethodInfo method)
 {
     this.declaringType = declaringType;
     this.method        = method;
     attributes         = new Lazy <Attributes>(() => new Attributes(method));
     returnAttributes   = new Lazy <Attributes>(() => new Attributes(method.ReturnParameter));
     genericParameters  = new Lazy <GenericParameterDeclarations>(() => new GenericParameterDeclarations(method));
     returnType         = TypeReferenceWithReflectionFactory.CreateReference(method.ReturnType, method);
     parameters         = new Lazy <Parameters <MethodParameterWithReflection> >(
         () => new Parameters <MethodParameterWithReflection>(method, parameter => new MethodParameterWithReflection(parameter)));
     body = new Lazy <ILMethodBodyWithReflectionEmit>(() => new ILMethodBodyWithReflectionEmit(method));
 }
        internal NestedDelegateWithReflection(ITypeWithReflection declaringType, Type type)
        {
            this.declaringType = declaringType;
            this.type          = type;
            attributes         = new Lazy <Attributes>(() => new Attributes(type));
            genericParameters  = new Lazy <GenericParameterDeclarations>(() => new GenericParameterDeclarations(type));
            MethodInfo method = type.GetMethod("Invoke");

            returnType = TypeReferenceWithReflectionFactory.CreateReference(method.ReturnType, method);
            parameters = new Lazy <Parameters <DelegateParameterWithReflection> >(
                () => new Parameters <DelegateParameterWithReflection>(method, parameter => new DelegateParameterWithReflection(parameter)));
        }
예제 #5
0
        internal PropertyWithReflection(ITypeWithReflection declaringType, PropertyInfo property)
        {
            this.declaringType = declaringType;
            this.property      = property;
            attributes         = new Lazy <Attributes>(() => new Attributes(property));
            propertyType       = TypeReferenceWithReflectionFactory.CreateReference(property.PropertyType, property);
            if (property.GetMethod != null)
            {
                getAccessor = new AccessorWithReflection(property.GetMethod);
            }

            if (property.SetMethod != null)
            {
                setAccessor = new AccessorWithReflection(property.SetMethod);
            }
        }
        internal IndexerWithReflection(ITypeWithReflection declaringType, PropertyInfo indexer)
        {
            this.declaringType = declaringType;
            this.indexer       = indexer;
            attributes         = new Lazy <Attributes>(() => new Attributes(indexer));
            indexerType        = TypeReferenceWithReflectionFactory.CreateReference(indexer.PropertyType, indexer);
            parameters         = new Lazy <Parameters <IndexerParameterWithReflection> >(
                () => new Parameters <IndexerParameterWithReflection>(indexer, parameter => new IndexerParameterWithReflection(parameter)));
            if (indexer.GetMethod != null)
            {
                getAccessor = new AccessorWithReflection(indexer.GetMethod);
            }

            if (indexer.SetMethod != null)
            {
                setAccessor = new AccessorWithReflection(indexer.SetMethod);
            }
        }
 public NewExpressionWithLinqExpressions(NewExpression expression)
 {
     Expression = expression;
     parameters = LinqExpressionBuilder.BuildExpressions(expression.Arguments);
     type       = TypeReferenceWithReflectionFactory.CreateReference(expression.Constructor.DeclaringType);
 }
예제 #8
0
 public DefaultExpressionWithLinqExpressions(DefaultExpression expression)
 {
     Expression = expression;
     type       = TypeReferenceWithReflectionFactory.CreateReference(expression.Type);
 }
예제 #9
0
 public GenericParameters(Type type, MemberInfo member)
 {
     GenericParametersWithReflection = type.GetGenericArguments()
                                       .Select(parameter => TypeReferenceWithReflectionFactory.CreateReference(parameter, member))
                                       .ToList();
 }
 public ParameterWithLinqExpressions(ParameterExpression expression)
 {
     Expression         = expression;
     this.parameterType = TypeReferenceWithReflectionFactory.CreateReference(expression.Type);
 }