/// <summary>Creates a modifiable deep copy clone of this <see cref="T:System.Windows.Annotations.ContentLocatorGroup" />.</summary> /// <returns>A modifiable deep copy clone of this <see cref="T:System.Windows.Annotations.ContentLocatorGroup" />.</returns> // Token: 0x06006342 RID: 25410 RVA: 0x001BEBB8 File Offset: 0x001BCDB8 public override object Clone() { ContentLocatorGroup contentLocatorGroup = new ContentLocatorGroup(); foreach (ContentLocator contentLocator in this._locators) { contentLocatorGroup.Locators.Add((ContentLocator)contentLocator.Clone()); } return(contentLocatorGroup); }
/// <summary> /// Merges this ContentLocator with a ContentLocatorBase. If other is a /// ContentLocatorGroup, each of its Locators are added to clones of /// this ContentLocatorBase and are added to a new ContentLocatorGroup which is /// returned. If other is a ContentLocatorBase, its appended to this /// ContentLocatorBase and this ContentLocatorBase is returned. /// Both operation modify this ContentLocatorBase. /// </summary> /// <param name="other">the ContentLocatorBase to merge with</param> /// <returns>a ContentLocatorBase containing the final merged product</returns> internal override ContentLocatorBase Merge(ContentLocatorBase other) { if (other == null) { return(this); } ContentLocatorGroup locatorGroup = other as ContentLocatorGroup; if (locatorGroup != null) { ContentLocatorGroup newGroup = new ContentLocatorGroup(); ContentLocator temp = null; // Create n-1 clones of this LPS and append all but one // LPSs in the set to the clones, adding the clones to a // new ContentLocatorGroup foreach (ContentLocator loc in locatorGroup.Locators) { if (temp == null) { temp = loc; } else { ContentLocator clone = (ContentLocator)this.Clone(); clone.Append(loc); newGroup.Locators.Add(clone); } } // Finally, add the remaining LPS in the set to this LPS // and add this to the new ContentLocatorGroup if (temp != null) { this.Append(temp); newGroup.Locators.Add(this); } if (newGroup.Locators.Count == 0) { return(this); } else { return(newGroup); } } else { // Safe cast - ContentLocator only has two subclasses this.Append((ContentLocator)other); return(this); } }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// Create a deep clone of this ContentLocatorGroup including clones of all /// the Locators it contains. /// </summary> /// <returns>a deep clone of this ContentLocatorGroup; never returns null</returns> public override Object Clone() { ContentLocatorGroup clone = new ContentLocatorGroup(); foreach (ContentLocator loc in _locators) { clone.Locators.Add((ContentLocator)loc.Clone()); } return clone; }
//------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods /// <summary> /// Create a deep clone of this ContentLocatorGroup including clones of all /// the Locators it contains. /// </summary> /// <returns>a deep clone of this ContentLocatorGroup; never returns null</returns> public override Object Clone() { ContentLocatorGroup clone = new ContentLocatorGroup(); foreach (ContentLocator loc in _locators) { clone.Locators.Add((ContentLocator)loc.Clone()); } return(clone); }
//------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods /// <summary> /// Merges the ContentLocatorGroup with a ContentLocatorBase. If other is a ContentLocatorBase, /// it is added to the end of every ContentLocatorBase in this ContentLocatorGroup. /// If other is a ContentLocatorGroup, then each ContentLocatorBase in it must be added to /// each ContentLocatorBase (or a clone) in this ContentLocatorGroup. The result is this /// ContentLocatorGroup will contain n*m ContentLocatorBase. /// In both cases, this ContentLocatorGroup is modified. /// </summary> /// <param name="other">other ContentLocatorBase to merge with</param> /// <returns>this ContentLocatorGroup</returns> internal override ContentLocatorBase Merge(ContentLocatorBase other) { if (other == null) { return(this); } ContentLocator firstRight = null; ContentLocatorGroup locatorGroup = other as ContentLocatorGroup; if (locatorGroup != null) { List <ContentLocatorBase> tempList = new List <ContentLocatorBase>(locatorGroup.Locators.Count * (this.Locators.Count - 1)); foreach (ContentLocator left in this.Locators) { foreach (ContentLocator right in locatorGroup.Locators) { if (firstRight == null) { firstRight = right; } else { ContentLocator clone = (ContentLocator)left.Clone(); clone.Append(right); tempList.Add(clone); } } // No need to clone or add here - just use the locator // already in the ContentLocatorGroup left.Append(firstRight); firstRight = null; } foreach (ContentLocator list in tempList) { this.Locators.Add(list); } } else { ContentLocator otherLoc = other as ContentLocator; Invariant.Assert(otherLoc != null, "other should be of type ContentLocator"); // Only other possible type for the ContentLocatorBase foreach (ContentLocator loc in this.Locators) { loc.Append(otherLoc); } } return(this); }
// Token: 0x06006347 RID: 25415 RVA: 0x001BED58 File Offset: 0x001BCF58 internal override ContentLocatorBase Merge(ContentLocatorBase other) { if (other == null) { return(this); } ContentLocator contentLocator = null; ContentLocatorGroup contentLocatorGroup = other as ContentLocatorGroup; if (contentLocatorGroup != null) { List <ContentLocatorBase> list = new List <ContentLocatorBase>(contentLocatorGroup.Locators.Count * (this.Locators.Count - 1)); foreach (ContentLocator contentLocator2 in this.Locators) { foreach (ContentLocator contentLocator3 in contentLocatorGroup.Locators) { if (contentLocator == null) { contentLocator = contentLocator3; } else { ContentLocator contentLocator4 = (ContentLocator)contentLocator2.Clone(); contentLocator4.Append(contentLocator3); list.Add(contentLocator4); } } contentLocator2.Append(contentLocator); contentLocator = null; } using (List <ContentLocatorBase> .Enumerator enumerator3 = list.GetEnumerator()) { while (enumerator3.MoveNext()) { ContentLocatorBase contentLocatorBase = enumerator3.Current; ContentLocator item = (ContentLocator)contentLocatorBase; this.Locators.Add(item); } return(this); } } ContentLocator contentLocator5 = other as ContentLocator; Invariant.Assert(contentLocator5 != null, "other should be of type ContentLocator"); foreach (ContentLocator contentLocator6 in this.Locators) { contentLocator6.Append(contentLocator5); } return(this); }
// Token: 0x0600633E RID: 25406 RVA: 0x001BEA54 File Offset: 0x001BCC54 internal override ContentLocatorBase Merge(ContentLocatorBase other) { if (other == null) { return(this); } ContentLocatorGroup contentLocatorGroup = other as ContentLocatorGroup; if (contentLocatorGroup == null) { this.Append((ContentLocator)other); return(this); } ContentLocatorGroup contentLocatorGroup2 = new ContentLocatorGroup(); ContentLocator contentLocator = null; foreach (ContentLocator contentLocator2 in contentLocatorGroup.Locators) { if (contentLocator == null) { contentLocator = contentLocator2; } else { ContentLocator contentLocator3 = (ContentLocator)this.Clone(); contentLocator3.Append(contentLocator2); contentLocatorGroup2.Locators.Add(contentLocator3); } } if (contentLocator != null) { this.Append(contentLocator); contentLocatorGroup2.Locators.Add(this); } if (contentLocatorGroup2.Locators.Count == 0) { return(this); } return(contentLocatorGroup2); }
/// <summary> /// Produces a set of locators that uses locator groups to /// span multiple branches in the tree. /// </summary> /// <param name="node">the PathNode identifying the root of the subtree to process</param> /// <param name="selection">the selection we are currently processing</param> /// <returns> /// a locator set containing locators identifying the path /// through the element tree /// </returns> /// <exception cref="ArgumentNullException">node is null</exception> /// <exception cref="SystemException">no AnnotationStore is available from /// the element tree</exception> private ContentLocatorBase GenerateLocatorGroup(PathNode node, Object selection) { Debug.Assert(node != null, "node can not be null"); SubTreeProcessor processor = GetSubTreeProcessor(node.Node); IList<ContentLocatorBase> tempLocators = null; ContentLocatorGroup ContentLocatorGroup = new ContentLocatorGroup(); // Produce a locator representing each child and add it // to the locator set. NOTE - We currently only support one // locator per branch. foreach (PathNode child in node.Children) { tempLocators = GenerateLocators(processor, child, selection); if (tempLocators != null && tempLocators.Count > 0) { // Don't add empty Locators to the ContentLocatorGroup if (tempLocators[0] != null) { ContentLocatorGroup locatorGroup = null; ContentLocator locator = tempLocators[0] as ContentLocator; if (locator != null && locator.Parts.Count != 0) { // NOTE - We currently only support producing one locator // per branch of the locator set. ContentLocatorGroup.Locators.Add(locator); } else if ((locatorGroup = tempLocators[0] as ContentLocatorGroup) != null) { // } } } } // If the locators set is empty, we return null // If only one locator was generated for the children, we return that // locator directly. No need for a ContentLocatorGroup // Otherwise return the ContentLocatorGroup if (ContentLocatorGroup.Locators.Count == 0) { return null; } else if (ContentLocatorGroup.Locators.Count == 1) { ContentLocator list = ContentLocatorGroup.Locators[0]; ContentLocatorGroup.Locators.Remove(list); return list; } else { return ContentLocatorGroup; } }
/// <summary> /// Merges this ContentLocator with a ContentLocatorBase. If other is a /// ContentLocatorGroup, each of its Locators are added to clones of /// this ContentLocatorBase and are added to a new ContentLocatorGroup which is /// returned. If other is a ContentLocatorBase, its appended to this /// ContentLocatorBase and this ContentLocatorBase is returned. /// Both operation modify this ContentLocatorBase. /// </summary> /// <param name="other">the ContentLocatorBase to merge with</param> /// <returns>a ContentLocatorBase containing the final merged product</returns> internal override ContentLocatorBase Merge(ContentLocatorBase other) { if (other == null) return this; ContentLocatorGroup locatorGroup = other as ContentLocatorGroup; if (locatorGroup != null) { ContentLocatorGroup newGroup = new ContentLocatorGroup(); ContentLocator temp = null; // Create n-1 clones of this LPS and append all but one // LPSs in the set to the clones, adding the clones to a // new ContentLocatorGroup foreach (ContentLocator loc in locatorGroup.Locators) { if (temp == null) { temp = loc; } else { ContentLocator clone = (ContentLocator)this.Clone(); clone.Append(loc); newGroup.Locators.Add(clone); } } // Finally, add the remaining LPS in the set to this LPS // and add this to the new ContentLocatorGroup if (temp != null) { this.Append(temp); newGroup.Locators.Add(this); } if (newGroup.Locators.Count == 0) return this; else return newGroup; } else { // Safe cast - ContentLocator only has two subclasses this.Append((ContentLocator)other); return this; } }