public static void PatchObject(T entity, ManahostPatcherModel[] operations) { ManahostEntityCaching instance = ManahostEntityCaching.Instance; Type entityType = typeof(T); foreach (ManahostPatcherModel operation in operations) { PatchField(entity, instance, entityType, operation.Field, operation.Value); } }
private static void PatchField(T entity, ManahostEntityCaching instance, Type entityType, String field, Object value) { PropertyInfo pInfoFromField = instance.RetrievePropertyInfoFromFieldName(entityType, field); if (pInfoFromField == null || Attribute.IsDefined(pInfoFromField, typeof(NotMappedAttribute)) || Attribute.IsDefined(pInfoFromField, typeof(IgnoreDataMemberAttribute)) || sforbiddenReplacement.Contains(field)) { return; } pInfoFromField.SetValue(entity, value); }