public object Imitate(DataImitateProvider provider, Type imitateType, object arrayObject)
        {
            var listType = typeof(List <>).MakeGenericType(GetElementType(imitateType));
            var list     = Activator.CreateInstance(listType);

            foreach (var item in (IEnumerable)arrayObject)
            {
                if (item == null)
                {
                    continue;
                }
                listType.InvokeMember("Add", BindingFlags.InvokeMethod, null, list,
                                      new[] { provider.Imitate(GetElementType(imitateType), item) });
            }
            return(Return(list, imitateType));
        }
        public object Imitate(DataImitateProvider provider, Type imitateType, object obj)
        {
            var newObject = Activator.CreateInstance(imitateType);

            foreach (var item in (IEnumerable <KeyValuePair <string, object> >)obj)
            {
                if (item.Value == null)
                {
                    continue;
                }
                var modelProp = imitateType.GetProperties().FirstOrDefault(x => provider.GetName(x) == item.Key);
                if (modelProp == null)
                {
                    continue;
                }
                var imitateValue = provider.Imitate(item.GetType(), item.Value);
                provider.SetValue(modelProp, newObject, imitateValue);
            }
            return(newObject);
        }
        public object Imitate(DataImitateProvider provider, Type imitateType, object obj)
        {
            if (obj == null)
            {
                return(null);
            }
            var props    = obj.GetType().GetProperties();
            var newModel = Activator.CreateInstance(imitateType);

            foreach (var prop in props)
            {
                var name      = provider.GetName(prop);
                var modelProp = imitateType.GetProperties().FirstOrDefault(x => x.Name == name);
                if (modelProp == null) // böyle bir property yok
                {
                    continue;
                }
                var value = prop.GetValue(obj);
                provider.SetValue(prop, newModel, provider.Imitate(value.GetType(), value));
            }
            return(newModel);
        }
 public object Imitate(DataImitateProvider provider, Type imitateType, object obj)
 {
     return(obj);
 }