public static DynamicPropertyDictionaryItemEntity ToEntity(this DynamicPropertyDictionaryItem model, DynamicPropertyEntity property) { var result = new DynamicPropertyDictionaryItemEntity(); result.InjectFrom(model); result.PropertyId = property.Id; if (model.DisplayNames != null) result.DisplayNames = new ObservableCollection<DynamicPropertyDictionaryItemNameEntity>(model.DisplayNames.Select(v => v.ToEntity())); return result; }
public static DynamicPropertyEntity ToEntity(this DynamicProperty model) { if (model == null) throw new ArgumentNullException("model"); var result = new DynamicPropertyEntity(); result.InjectFrom(model); if (model.ValueType != DynamicPropertyValueType.Undefined) result.ValueType = model.ValueType.ToString(); if (model.DisplayNames != null) result.DisplayNames = new ObservableCollection<DynamicPropertyNameEntity>(model.DisplayNames.Select(n => n.ToEntity())); return result; }
public static void Patch(this DynamicPropertyEntity source, DynamicPropertyEntity target) { if (target == null) throw new ArgumentNullException("target"); var patchInjectionPolicy = new PatchInjection<DynamicPropertyEntity>(x => x.Name, x => x.IsRequired, x => x.IsArray); target.InjectFrom(patchInjectionPolicy, source); if (!source.DisplayNames.IsNullCollection()) { var comparer = AnonymousComparer.Create((DynamicPropertyNameEntity x) => string.Join("-", x.Locale, x.Name)); source.DisplayNames.Patch(target.DisplayNames, comparer, (sourceItem, targetItem) => { }); } if (!source.ObjectValues.IsNullCollection()) { source.ObjectValues.Patch(target.ObjectValues, new DynamicPropertyObjectValueComparer(), (sourceValue, targetValue) => sourceValue.Patch(targetValue)); } }
public virtual void Patch(DynamicPropertyEntity target) { target.Name = Name; target.Description = Description; target.IsRequired = IsRequired; target.IsArray = IsArray; target.DisplayOrder = DisplayOrder; if (!DisplayNames.IsNullCollection()) { var comparer = AnonymousComparer.Create((DynamicPropertyNameEntity x) => string.Join("-", x.Locale, x.Name)); DisplayNames.Patch(target.DisplayNames, comparer, (sourceItem, targetItem) => { }); } //if (!ObjectValues.IsNullCollection()) //{ // var comparer = AnonymousComparer.Create((DynamicPropertyObjectValueEntity x) => $"{x.ObjectId}:{x.ObjectType}:{x.Locale}:{x.GetValue(EnumUtility.SafeParse(x.ValueType, DynamicPropertyValueType.LongText))}"); // ObjectValues.Patch(target.ObjectValues, comparer, (sourceValue, targetValue) => sourceValue.Patch(targetValue)); //} }