Beispiel #1
0
 private static void ProcessObject(object obj, string path, IDictionary <String, EntityProperty> entities)
 {
     obj.GetType().GetProperties().Where(propertyInfo => propertyInfo.CanRead && propertyInfo.CanWrite).ToList().ForEach(propertyInfo => {
         string id         = propertyInfo.Name;
         string entityName = BuildEntityName(path, id);
         if (entities.ContainsKey(entityName))
         {
             Type pType           = propertyInfo.PropertyType;
             IConverter converter = ConveterFactory.FindConverter(pType);
             if (converter != null)
             {
                 propertyInfo.SetValue(obj, converter.BuildValue(entities[entityName], pType), index: null);
             }
             else
             {
                 if (pType.IsValueType)
                 {
                     throw new ConverterException("No convertor found for: " + id + " / " + pType.ToString());
                 }
                 object child = FormatterServices.GetUninitializedObject(pType);
                 ProcessObject(child, id, entities);
             }
         }
     });
 }