public new static ListeSonuc <TEntity> Basarisiz(params Hata[] errors) { var result = new ListeSonuc <TEntity> { Basarili = false }; if (errors != null) { result._errors.AddRange(errors); } return(result); }
public static ListeSonuc <TSource> ShapeData <TSource>( this ListeSonuc <TSource> source, string fields = null) { if (source == null) { throw new ArgumentException("kaynak boş olamaz!"); } var expandoObjectList = new List <ExpandoObject>(); var propertyInfoList = new List <PropertyInfo>(); if (string.IsNullOrWhiteSpace(fields)) { return(source); //var propertyInfos = typeof(TSource).GetProperties(BindingFlags.Public | BindingFlags.Instance); //propertyInfoList.AddRange(propertyInfos); } else { var fieldsAfterSplit = fields.Split(','); foreach (var field in fieldsAfterSplit) { var propertyName = field.Trim(); var propertyInfo = typeof(TSource).GetProperty(propertyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance); if (propertyInfo == null) { throw new Exception($"Proeprty {propertyName} wasn't found on {typeof(TSource)}."); } propertyInfoList.Add(propertyInfo); } } foreach (TSource sourceObject in source.DonenListe) { var dataShapedObject = new ExpandoObject(); foreach (var propertyInfo in propertyInfoList) { var propertyValue = propertyInfo.GetValue(sourceObject); dataShapedObject.TryAdd(propertyInfo.Name, propertyValue); } expandoObjectList.Add(dataShapedObject); } source.DonenSekillenmisListe = expandoObjectList; source.DonenListe = null; return(source); }