public void AddTo(DetailCollection newEnclosingCollection) { RemoveFromEnclosingCollection(); if (newEnclosingCollection != null) { newEnclosingCollection.Add(newEnclosingCollection); } }
public override bool Equals(object obj) { if (this == obj) { return(true); } DetailCollection other = obj as DetailCollection; return(other != null && id != 0 && id == other.id); }
/// <summary>Clones the collection and </summary> /// <returns></returns> public virtual DetailCollection Clone() { DetailCollection collection = new DetailCollection(); collection.ID = 0; collection.Name = this.Name; collection.EnclosingItem = this.EnclosingItem; foreach (ContentDetail detail in this.Details) { ContentDetail cloned = detail.Clone(); cloned.EnclosingCollection = collection; collection.Add(cloned); } return collection; }
/// <summary>Gets a named detail collection.</summary> /// <param name="collectionName">The name of the detail collection to get.</param> /// <param name="createWhenEmpty">Wether a new collection should be created if none exists. Setting this to false means null will be returned if no collection exists.</param> /// <returns>A new or existing detail collection or null if the createWhenEmpty parameter is false and no collection with the given name exists..</returns> public virtual Details.DetailCollection GetDetailCollection(string collectionName, bool createWhenEmpty) { if (DetailCollections.ContainsKey(collectionName)) { return(DetailCollections[collectionName]); } else if (createWhenEmpty) { Details.DetailCollection collection = new Details.DetailCollection(this, collectionName); DetailCollections.Add(collectionName, collection); return(collection); } else { return(null); } }
static void CloneDetails(ContentItem source, ContentItem destination) { foreach (Details.ContentDetail detail in source.Details.Values) { if (destination.details.ContainsKey(detail.Name)) { destination.details[detail.Name].Value = detail.Value; //.Value should behave polymorphically } else { ContentDetail clonedDetail = detail.Clone(); clonedDetail.EnclosingItem = destination; destination.details[detail.Name] = clonedDetail; } } foreach (Details.DetailCollection collection in source.DetailCollections.Values) { Details.DetailCollection clonedCollection = collection.Clone(); clonedCollection.EnclosingItem = destination; destination.DetailCollections[collection.Name] = clonedCollection; } }
public DetailCollectionEnumerator(DetailCollection collection) { this.collection = collection; }