コード例 #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();
            }
        }
コード例 #2
0
        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));
 }
コード例 #4
0
        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);
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 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();
 }
コード例 #10
0
 public ParameterWithLinqExpressions(ParameterExpression expression)
 {
     Expression         = expression;
     this.parameterType = TypeReferenceWithReflectionFactory.CreateReference(expression.Type);
 }