コード例 #1
0
 internal FieldGroupWithReflection(ITypeWithReflection declaringType, FieldInfo field)
 {
     this.declaringType = declaringType;
     this.field         = field;
     attributes         = new Lazy <Attributes>(() => new Attributes(field));
     fieldType          = TypeReferenceWithReflectionFactory.CreateReference(field.FieldType, field);
 }
コード例 #2
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();
            }
        }
コード例 #3
0
 internal ConstantGroupWithReflection(ITypeWithReflection declaringType, FieldInfo field)
 {
     this.declaringType = declaringType;
     this.field         = field;
     attributes         = new Lazy <Attributes>(() => new Attributes(field));
     fieldType          = TypeReferenceWithReflectionFactory.CreateReference(field.FieldType, field);
     constantValue      = new Lazy <IConstantExpressionWithReflection>(
         () => ConstantExpressionFactory.CreateExpression(field.GetValue(null)));
 }
コード例 #4
0
        public NewArrayExpressionWithLinqExpressions(NewArrayExpression expression)
        {
            Expression = expression;
            dimensions = new List <int>();
            for (Type arrayType = expression.Type; arrayType.IsArray; arrayType = arrayType.GetElementType())
            {
                dimensions.Add(arrayType.GetArrayRank());
            }

            elementType            = TypeReferenceWithReflectionFactory.CreateReference(expression.Type.GetElementType());
            initialSizeExpressions = LinqExpressionBuilder.BuildExpressions(expression.Expressions);
        }
コード例 #5
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);
        }
コード例 #6
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));
 }
コード例 #7
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)));
        }
コード例 #8
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);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
 public CatchStatementWithLinqExpressions(CatchBlock statement)
 {
     Statement  = statement;
     type       = TypeReferenceWithReflectionFactory.CreateReference(statement.Test);
     statements = LinqStatementBuilder.BuildStatements(statement.Body);
 }
コード例 #11
0
 public ParameterSignature(ParameterInfo parameter)
 {
     modifier      = parameter.Modifier();
     name          = string.Format("parameter{0}", parameter.Position + 1);
     parameterType = TypeReferenceWithReflectionFactory.CreateReference(parameter.ParameterType);
 }
コード例 #12
0
 public NewExpressionWithLinqExpressions(NewExpression expression)
 {
     Expression = expression;
     parameters = LinqExpressionBuilder.BuildExpressions(expression.Arguments);
     type       = TypeReferenceWithReflectionFactory.CreateReference(expression.Constructor.DeclaringType);
 }
コード例 #13
0
 public DefaultExpressionWithLinqExpressions(DefaultExpression expression)
 {
     Expression = expression;
     type       = TypeReferenceWithReflectionFactory.CreateReference(expression.Type);
 }
コード例 #14
0
 public GenericParameters(Type type, MemberInfo member)
 {
     GenericParametersWithReflection = type.GetGenericArguments()
                                       .Select(parameter => TypeReferenceWithReflectionFactory.CreateReference(parameter, member))
                                       .ToList();
 }
コード例 #15
0
 public ParameterWithLinqExpressions(ParameterExpression expression)
 {
     Expression         = expression;
     this.parameterType = TypeReferenceWithReflectionFactory.CreateReference(expression.Type);
 }