Esempio n. 1
0
        private void AnalyzeTypeType(Type type)
        {
            ObjectType objectType = new ObjectType(type.GenericFullName(), "Tuple of values.", null);

              foreach (var property in type.GetProperties(BindingFlags.Instance | BindingFlags.Public))
              {
            AnalyzeType(objectType, property);
              }

              objectType.Validate();

              this.types.Add(objectType.Name, objectType);
        }
Esempio n. 2
0
        private void AnalyzeSerializableType(Type type)
        {
            var soa = (SerializeObjectAttribute)type.GetCustomAttributes(this.serializeObjectAttribute, false).SingleOrDefault();

              if (soa != null)
              {
            ObjectType inherits = null;

            if (type.BaseType != typeof(object))
            {
              if (!this.types.ContainsKey(type.BaseType.GenericFullName()))
              {
            AnalyzeType(type.BaseType);
              }

              inherits = this.types[type.BaseType.GenericFullName()] as ObjectType;
            }

            ObjectType objectType = new ObjectType(type.GenericFullName(), soa.Comment, inherits);

            foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
              if (field.DeclaringType == type)
              {
            AnalyzeType(objectType, field);
              }
            }

            foreach (PropertyInfo property in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
              if (property.DeclaringType == type)
              {
            AnalyzeType(objectType, property);
              }
            }

            if (soa == null)
            {
              Console.WriteLine("  Serialize Object Attribute on type " + type.FullName + " missing");
              Console.ReadLine();
            }

            objectType.Validate();

            this.types.Add(objectType.Name, objectType);
              }
              else
              {
            Console.WriteLine("Type {0} has no SerializeObjectAttribute!", type.FullName);
            Console.ReadLine();
              }
        }