public static PropertyFlattenerFactory Flattener()
 {
     if (factory == null)
     {
         factory = new PropertyFlattenerFactory();
     }
     return(factory);
 }
예제 #2
0
        public Product Flatten(JObject jObj)
        {
            var product = jObj.ToObject <Product>();
            List <IProductProperty> props = new List <IProductProperty>();

            foreach (var group in jObj.Properties().Where(p => p.Value.Type == JTokenType.Object || p.Value.Type == JTokenType.Array))
            {
                IPropertyFlattener flattener = PropertyFlattenerFactory.Flattener().For(group.Name);
                var properties = flattener.Flatten(group.Value, string.Empty, null);
                product.AddProperties(group.Name, properties);
            }

            return(product);
        }