Beispiel #1
0
 public Property(PropertyInfo info)
 {
     Name           = info.Name;
     Type           = SingletonDictionary <ReflectedType> .Types[info.PropertyType.Name];
     PropertyAccess = (info.CanRead && (!info.CanWrite)) ? Access.ReadOnly : Access.ReadWrite;
     GetSetMethods(info);
 }
Beispiel #2
0
        private ReflectedType GetType(FieldInfo info)
        {
            if (!SingletonDictionary <ReflectedType> .Types.ContainsKey(info.FieldType.Name))
            {
                ReflectedType reflectedType = new ReflectedType(info.FieldType);
                if (!SingletonDictionary <ReflectedType> .Types.ContainsKey(reflectedType.Name))
                {
                    SingletonDictionary <ReflectedType> .Types.Add(info.FieldType.Name, reflectedType);
                }
            }

            return(SingletonDictionary <ReflectedType> .Types[info.FieldType.Name]);
        }
Beispiel #3
0
 public void AddElement(ReflectedType type)
 {
     if (type != null)
     {
         if (type.TypeKind == Kind.Class)
         {
             Classes.Add(type);
         }
         else if (type.TypeKind == Kind.Interface)
         {
             Interfaces.Add(type);
         }
         else if (type.TypeKind == Kind.Enum || type.TypeKind == Kind.Struct)
         {
             ValueTypes.Add(type);
         }
     }
 }
        public void Reflect()
        {
            //load namespaces
            foreach (string ns in _assembly.GetTypes().Select(x => x.Namespace).Distinct())
            {
                Namespaces.Add(new Namespace(ns));
            }

            //add types to namespaces
            foreach (Type type in _assembly.GetTypes())
            {
                ReflectedType reflectedType = new ReflectedType(type);
                Namespaces.Find(x => x.Name == type.Namespace).AddElement(reflectedType);
                if (!SingletonDictionary <ReflectedType> .Types.ContainsKey(reflectedType.Name))
                {
                    SingletonDictionary <ReflectedType> .Types.Add(reflectedType.Name, new ReflectedType(reflectedType.Name, reflectedType.Namespace));
                }
                SingletonDictionary <ReflectedType> .Types[type.Name].AnalyzeType(type);
            }
        }
Beispiel #5
0
 public Field(FieldInfo info)
 {
     Name   = info.Name;
     Access = GetAccess(info);
     Type   = GetType(info);
 }
Beispiel #6
0
 public Parameter(string name, Type paramType)
 {
     Name      = name;
     ParamType = new ReflectedType(paramType.Name, paramType.Namespace);
 }