コード例 #1
0
ファイル: BoxFactory.cs プロジェクト: zhu7478848/config
      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;
         }
      }
コード例 #2
0
 public DynamicEnumerator(int count, CollectionResultBox parent)
 {
     _count  = count;
     _parent = parent;
 }