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);
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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)));
 }
        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);
        }
        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);
        }
Ejemplo n.º 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));
 }
        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)));
        }
Ejemplo n.º 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);
            }
        }
        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);
            }
        }
Ejemplo n.º 10
0
 public CatchStatementWithLinqExpressions(CatchBlock statement)
 {
     Statement  = statement;
     type       = TypeReferenceWithReflectionFactory.CreateReference(statement.Test);
     statements = LinqStatementBuilder.BuildStatements(statement.Body);
 }
Ejemplo n.º 11
0
 public ParameterSignature(ParameterInfo parameter)
 {
     modifier      = parameter.Modifier();
     name          = string.Format("parameter{0}", parameter.Position + 1);
     parameterType = TypeReferenceWithReflectionFactory.CreateReference(parameter.ParameterType);
 }
 public NewExpressionWithLinqExpressions(NewExpression expression)
 {
     Expression = expression;
     parameters = LinqExpressionBuilder.BuildExpressions(expression.Arguments);
     type       = TypeReferenceWithReflectionFactory.CreateReference(expression.Constructor.DeclaringType);
 }
Ejemplo n.º 13
0
 public DefaultExpressionWithLinqExpressions(DefaultExpression expression)
 {
     Expression = expression;
     type       = TypeReferenceWithReflectionFactory.CreateReference(expression.Type);
 }
Ejemplo n.º 14
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);
 }