Exemplo n.º 1
0
        public AstReflectedType(Type type, Reflector reflector)
        {
            Argument.RequireNotNull("type", type);
            Argument.RequireNotNull("reflector", reflector);

            this.ActualType = type;
            this.reflector = reflector;
            this.baseType = this.ActualType.BaseType != null
                          ? new Lazy<IAstTypeReference>(() => this.reflector.Reflect(this.ActualType.BaseType))
                          : new Lazy<IAstTypeReference>(() => AstAnyType.Instance);
        }
Exemplo n.º 2
0
        public ExternalNamespaceNameSource(string @namespace, IEnumerable<Assembly> assemblies, Reflector reflector)
        {
            this.reflector = reflector;
            Argument.RequireNotNullAndNotEmpty("namespace", @namespace);
            Argument.RequireNotNull("assemblies", assemblies);

            // this all is horribly inefficient, especially if using multiple namespaces from a single assembly
            // but it can wait for now
            this.typeCache = assemblies.SelectMany(a => a.GetExportedTypes())
                                       .Where(t => t.Namespace == @namespace)
                                       .ToDictionary(t => t.Name);

            if (this.typeCache.Count == 0)
                throw new NotImplementedException("ExternalNamespaceNameSource: No types in " + @namespace);

            this.memberCache = this.typeCache.Values
                                             .SelectMany(t => t.GetMethods())
                                             .Where(m => m.IsStatic)
                                             .Where(m => m.IsDefined<ExtensionAttribute>(false))
                                             .GroupBy(m => m.Name)
                                             .ToDictionary(g => g.Key, g => g.ToArray());
        }
Exemplo n.º 3
0
        public AstReflectedMethod(MethodInfo method, Reflector reflector)
        {
            Argument.RequireNotNull("reflector", reflector);
            Argument.RequireNotNull("method", method);

            this.Method = method;
            this.ReturnType = method.ReturnType != typeof(void)
                            ? reflector.Reflect(method.ReturnType)
                            : AstVoidType.Instance;

            this.parameterTypes = new Lazy<ReadOnlyCollection<IAstTypeReference>>(
                () => method.GetParameters()
                            .Select(p => reflector.Reflect(p.ParameterType))
                            .ToArray()
                            .AsReadOnly()
            );

            this.genericParameterTypes = new Lazy<ReadOnlyCollection<IAstTypeReference>>(
                () => method.IsGenericMethodDefinition ? method.GetGenericArguments().Select(reflector.Reflect).ToArray().AsReadOnly() : No.Types
            );

            this.Location = method.IsDefined<ExtensionAttribute>(false) ? MethodLocation.Extension : MethodLocation.Target;
        }
Exemplo n.º 4
0
 public AstReflectedProperty(PropertyInfo property, Reflector reflector)
 {
     Argument.RequireNotNull("property", property);
     this.Property = property;
     this.Type = new AstReflectedType(property.PropertyType, reflector);
 }
Exemplo n.º 5
0
 public AstReflectedConstructor(ConstructorInfo constructor, Reflector reflector)
 {
     this.Constructor = constructor;
 }
Exemplo n.º 6
0
 public BuiltInNamespacesNameSource(Reflector reflector)
 {
     this.namespaces = new[] {
         new ExternalNamespaceNameSource("Light.Framework", new[] { typeof(Range<>).Assembly }, reflector),
     };
 }
Exemplo n.º 7
0
 public BuiltInTypesNameSource(BuiltInTypeMap map, Reflector reflector)
 {
     this.map = map;
     this.reflector = reflector;
 }