/// <summary> /// Removes a ContentType with the supplied alias from the the list of composite ContentTypes /// </summary> /// <param name="alias">Alias of a <see cref="ContentType"/></param> /// <returns>True if ContentType was removed, otherwise returns False</returns> public bool RemoveContentType(string alias) { if (ContentTypeCompositionExists(alias)) { var contentTypeComposition = ContentTypeComposition.First(x => x.Alias == alias); RemovedContentTypeKeyTracker.Add(contentTypeComposition.Id); OnPropertyChanged(ContentTypeCompositionSelector); return(_contentTypeComposition.Remove(contentTypeComposition)); } return(false); }
/// <summary> /// Checks if a ContentType with the supplied alias exists in the list of composite ContentTypes /// </summary> /// <param name="alias">Alias of a <see cref="ContentType"/></param> /// <returns>True if ContentType with alias exists, otherwise returns False</returns> public bool ContentTypeCompositionExists(string alias) { if (ContentTypeComposition.Any(x => x.Alias.Equals(alias))) { return(true); } if (ContentTypeComposition.Any(x => x.ContentTypeCompositionExists(alias))) { return(true); } return(false); }
public override object DeepClone() { var clone = (ContentTypeCompositionBase)base.DeepClone(); //turn off change tracking clone.DisableChangeTracking(); //need to manually assign since this is an internal field and will not be automatically mapped clone.RemovedContentTypeKeyTracker = new List <int>(); clone._contentTypeComposition = ContentTypeComposition.Select(x => (IContentTypeComposition)x.DeepClone()).ToList(); //this shouldn't really be needed since we're not tracking clone.ResetDirtyProperties(false); //re-enable tracking clone.EnableChangeTracking(); return(clone); }
/// <summary> /// Removes a content type with a specified alias from the composition. /// </summary> /// <param name="alias">The alias of the content type to remove.</param> /// <returns>True if the content type was removed, otherwise false.</returns> public bool RemoveContentType(string alias) { if (ContentTypeCompositionExists(alias)) { var contentTypeComposition = ContentTypeComposition.FirstOrDefault(x => x.Alias == alias); if (contentTypeComposition == null)//You can't remove a composition from another composition { return(false); } RemovedContentTypeKeyTracker.Add(contentTypeComposition.Id); //If the ContentType we are removing has Compositions of its own these needs to be removed as well var compositionIdsToRemove = contentTypeComposition.CompositionIds().ToList(); if (compositionIdsToRemove.Any()) { RemovedContentTypeKeyTracker.AddRange(compositionIdsToRemove); } OnPropertyChanged(Ps.Value.ContentTypeCompositionSelector); return(_contentTypeComposition.Remove(contentTypeComposition)); } return(false); }
/// <summary> /// Gets a list of ContentType Ids from the current composition /// </summary> /// <returns>An enumerable list of integer ids</returns> /// <remarks>Does not contain the Id of the Current ContentType</remarks> public IEnumerable <int> CompositionIds() { return(ContentTypeComposition .Select(x => x.Id) .Union(ContentTypeComposition.SelectMany(x => x.CompositionIds()))); }
/// <summary> /// Gets a list of ContentType aliases from the current composition /// </summary> /// <returns>An enumerable list of string aliases</returns> /// <remarks>Does not contain the alias of the Current ContentType</remarks> public IEnumerable <string> CompositionAliases() { return(ContentTypeComposition .Select(x => x.Alias) .Union(ContentTypeComposition.SelectMany(x => x.CompositionAliases()))); }