/// <summary> /// Moves a PropertyType to a specified PropertyGroup /// </summary> /// <param name="propertyTypeAlias">Alias of the PropertyType to move</param> /// <param name="propertyGroupName">Name of the PropertyGroup to move the PropertyType to</param> /// <returns></returns> public bool MovePropertyType(string propertyTypeAlias, string propertyGroupName) { if (PropertyTypes.Any(x => x.Alias == propertyTypeAlias) == false || PropertyGroups.Any(x => x.Name == propertyGroupName) == false) { return(false); } var propertyType = PropertyTypes.First(x => x.Alias == propertyTypeAlias); //The PropertyType already belongs to a PropertyGroup, so we have to remove the PropertyType from that group if (PropertyGroups.Any(x => x.PropertyTypes.Any(y => y.Alias == propertyTypeAlias))) { var oldPropertyGroup = PropertyGroups.First(x => x.PropertyTypes.Any(y => y.Alias == propertyTypeAlias)); oldPropertyGroup.PropertyTypes.RemoveItem(propertyTypeAlias); } propertyType.PropertyGroupId = new Lazy <int>(() => default(int)); propertyType.ResetDirtyProperties(); var propertyGroup = PropertyGroups.First(x => x.Name == propertyGroupName); propertyGroup.PropertyTypes.Add(propertyType); return(true); }
/// <summary> /// Indicates whether the current entity is dirty. /// </summary> /// <returns>True if entity is dirty, otherwise False</returns> public override bool IsDirty() { bool dirtyEntity = base.IsDirty(); bool dirtyGroups = PropertyGroups.Any(x => x.IsDirty()); bool dirtyTypes = PropertyTypes.Any(x => x.IsDirty()); return(dirtyEntity || dirtyGroups || dirtyTypes); }
/// <summary> /// Indicates whether a specific property on the current <see cref="IContent"/> entity is dirty. /// </summary> /// <param name="propertyName">Name of the property to check</param> /// <returns>True if Property is dirty, otherwise False</returns> public override bool IsPropertyDirty(string propertyName) { bool existsInEntity = base.IsPropertyDirty(propertyName); bool anyDirtyGroups = PropertyGroups.Any(x => x.IsPropertyDirty(propertyName)); bool anyDirtyTypes = PropertyTypes.Any(x => x.IsPropertyDirty(propertyName)); return(existsInEntity || anyDirtyGroups || anyDirtyTypes); }