Ejemplo n.º 1
0
      private static void DiscoverProperties(Type t, ValueHandler valueHandler, Dictionary<string, ResultBox> result, string basePath)
      {
         IEnumerable<PropertyInfo> properties = GetHierarchyPublicProperties(t);

         foreach (PropertyInfo pi in properties)
         {
            Type propertyType = pi.PropertyType;
            ResultBox rbox;
            bool isCollection = false;

            if(ResultBox.TryGetCollection(propertyType, out propertyType))
            {
               if(pi.SetMethod != null)
               {
                  throw new NotSupportedException($"Collection properties cannot have a setter. Detected at '{OptionPath.Combine(basePath, pi.Name)}'");
               }

               isCollection = true;
            }

            if(propertyType.GetTypeInfo().IsInterface)
            {
               rbox = new ProxyResultBox(pi.Name, propertyType);
            }
            else
            {
               rbox = new PropertyResultBox(pi.Name, propertyType);
            }

            ValidateSupportedType(rbox, valueHandler);

            AddAttributes(rbox, pi, valueHandler);

            //adjust to collection
            if(isCollection)
            {
               rbox = new CollectionResultBox(pi.Name, rbox);
            }

            result[pi.Name] = rbox;
         }
      }
Ejemplo n.º 2
0
 public DynamicEnumerator(int count, CollectionResultBox parent)
 {
     _count  = count;
     _parent = parent;
 }