internal DefinitionLocator CreateCopyForMerging() { DefinitionLocator copy = new DefinitionLocator(); copy.CopyLocatorBaseInformation(this); if (this.childDisplayOrder != null) { copy.childDisplayOrder = new HybridDictionary(); foreach (DictionaryEntry de1 in this.childDisplayOrder) { copy.childDisplayOrder[de1.Key] = de1.Value; } } if (this.childLocatorsByHRef != null) { copy.childLocatorsByHRef = new HybridDictionary(); foreach (DictionaryEntry de1 in this.childLocatorsByHRef) { ChildDefinitionLocator cdl = de1.Value as ChildDefinitionLocator; copy.childLocatorsByHRef[de1.Key] = cdl.CreateCopyForMerging(); } } //parent info udjused later copy.parents = this.parents; return(copy); }
internal void Append(DefinitionLocator arg) { if (arg.childLocatorsByHRef != null) { if (this.childLocatorsByHRef == null) { this.childLocatorsByHRef = new HybridDictionary(); this.childDisplayOrder = new HybridDictionary(); } foreach (ChildDefinitionLocator cpl in arg.childLocatorsByHRef.Values) { ChildDefinitionLocator orig = this.childLocatorsByHRef[cpl.HRef] as ChildDefinitionLocator; if (orig == null) { childLocatorsByHRef[cpl.HRef] = cpl; } else { foreach (DefinitionLocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos) { if (orig.CanAddRelationship(lri)) { orig.AddRelationship(lri); } } } } } if (arg.parents != null && arg.parents.Count > 0) { if (parents == null) { parents = arg.parents; } else { // unique parents only please foreach (DefinitionLocator parent in arg.Parents) { if (!parents.Contains(parent)) { parents.Add(parent); } } } } foreach (string label in arg.labelArray) { AddLabel(label); } }
internal void AddParent(DefinitionLocator parent) { if (parents == null) { parents = new ArrayList(); } // BUG 1610 - don't add duplicate parents if (!parents.Contains(parent)) { parents.Add(parent); } }
/// <summary> /// Overloaded. Creates a new instance of <see cref="DefinitionLocator"/> and /// initializes its properties from a parameter-supplied <see cref="DefinitionLocator"/>. /// </summary> public DefinitionLocator(DefinitionLocator copy) { this.childLocatorsByHRef = copy.childLocatorsByHRef; this.childDisplayOrder = copy.childDisplayOrder; this.e = copy.e; this.HRef = copy.HRef; this.LabelArray = copy.LabelArray; this.e = copy.MyElement; this.parents = copy.parents; this.unpartitionedHref = copy.unpartitionedHref; this.xsd = copy.xsd; }
internal void AddChild(DefinitionLocator childPl, float orderArg, string prefLabel, string targetRole, bool?isClosed, bool?isUsable, bool?isall, bool?isScenario, bool?isDefault, bool?isRequiresElement, DimensionNode.NodeType nodeType, string priority, bool isProhibited) { childPl.AddParent(this); if (this.childLocatorsByHRef == null) { this.childLocatorsByHRef = new HybridDictionary(); this.childDisplayOrder = new HybridDictionary(); } float dispOrder = orderArg; DefinitionLocatorRelationshipInfo newRelation = DefinitionLocatorRelationshipInfo.CreateObj(prefLabel, priority, orderArg, dispOrder, prefLabel, isProhibited, targetRole, isClosed, isUsable, isall, isScenario, isRequiresElement, isDefault, nodeType); ChildDefinitionLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildDefinitionLocator; if (cpl == null) { // doesn't exist in either the href table or the order table cpl = new ChildDefinitionLocator(childPl.HRef, newRelation); childLocatorsByHRef.Add(childPl.HRef, cpl); // keep these separate so they don't impact each other ChildDefinitionLocator cplOrder = new ChildDefinitionLocator(cpl); } else { // the cpl already exists, append the existing relation info cpl.AddRelationship(newRelation); } }
/// <summary> /// Map the parent values back to the new locator list /// </summary> /// <param name="newLocatorList"></param> internal void ResetParentInformation(Hashtable newLocatorList) { if (this.parents != null && this.parents.Count > 0) { ArrayList newList = new ArrayList(this.parents.Count); for (int i = 0; i < this.parents.Count; i++) { DefinitionLocator dl = parents[i] as DefinitionLocator; DefinitionLocator newdl = newLocatorList[dl.href] as DefinitionLocator; if (newdl != null) { newList.Add(newdl); } else { throw new ApplicationException("Failed to find corresponding parent values"); } } this.parents = newList; } }
public bool UpdateOptionalArc(string elementId, string parentElementId, DefinitionLocatorRelationshipInfo newLocatorRelationshipInfo, Taxonomy taxonomy) { DefinitionLocator parentLocator = locators[parentElementId] as DefinitionLocator; newLocatorRelationshipInfo.IsProhibited = false; newLocatorRelationshipInfo.OrigOrder = newLocatorRelationshipInfo.Order; if (parentLocator == null && !string.IsNullOrEmpty(parentElementId)) { parentLocator = new DefinitionLocator(); parentLocator.href = parentElementId; parentLocator.MyElement = taxonomy.allElements[parentElementId] as Element; locators[parentElementId] = parentLocator; } DefinitionLocator childLocator = locators[elementId] as DefinitionLocator; if (childLocator == null) { childLocator = new DefinitionLocator(); childLocator.href = elementId; childLocator.MyElement = taxonomy.allElements[elementId] as Element; if (parentLocator != null) { childLocator.AddParent(parentLocator); } locators[elementId] = childLocator; } if (parentLocator != null) { if (parentLocator.childLocatorsByHRef == null) { parentLocator.childLocatorsByHRef = new HybridDictionary(); } ChildDefinitionLocator cpl = parentLocator.childLocatorsByHRef[elementId] as ChildDefinitionLocator; if (cpl != null) { cpl.AddRelationship(newLocatorRelationshipInfo); } else { cpl = new ChildDefinitionLocator(elementId, newLocatorRelationshipInfo); parentLocator.childLocatorsByHRef[elementId] = cpl; } } return true; }
/// <summary> /// Retrieve a <see cref="DefinitionLocator"/> for this <see cref="DefinitionLink"/>'s locators /// collection by URI (href). /// </summary> /// <param name="href">The URI (href) of the locator to be retrieved.</param> /// <param name="locator">If return value is true, the retrieved locator.</param> /// <returns>True if the requested <see cref="DefinitionLocator"/> occurs in this <see cref="DefinitionLink"/>'s locators /// collection.</returns> public bool TryGetLocator( string href, out DefinitionLocator locator ) { locator = null; if ( locators == null ) { return false; } locator = locators[href] as DefinitionLocator; return locator != null; }
DefinitionLocator RecursivelyGetParentLocatorForMember(DefinitionLocator currentDL, ref List<string> locsChecked, string childId ) { if (locsChecked.Contains(currentDL.href)) return null; //to avoid recursion locsChecked.Add(currentDL.href); if (currentDL.childLocatorsByHRef != null) { foreach (ChildDefinitionLocator cpl in currentDL.childLocatorsByHRef.Values) { bool useChild = false; foreach (DefinitionLocatorRelationshipInfo dri in cpl.LocatorRelationshipInfos) { if (!dri.IsProhibited) { useChild = true; } } if (!useChild) continue; if (cpl.HRef.Equals(childId)) { return currentDL; } DefinitionLocator childDL = this.locators[cpl.HRef] as DefinitionLocator; if (childDL != null) { DefinitionLocator ret = RecursivelyGetParentLocatorForMember(childDL, ref locsChecked, childId); if (ret != null) return ret; } } } return null; }
/// <summary> /// Compares this instance of <see cref="DefinitionLocator"/> to a supplied <see cref="Object"/>. /// </summary> /// <param name="obj">An <see cref="object"/> to which this instance of <see cref="DefinitionLocator"/> /// is to be compared. Assumed to be a <see cref="DefinitionLocator"/>.</param> /// <returns>An <see cref="int"/> indicating if <paramref name="obj"/> is less than (<0), /// greater than (>0), or equal to (0) this instance of <see cref="DefinitionLocator"/>.</returns> /// <remarks>This comparison is equivalent to the results of <see cref="String.Compare(String, String)"/> /// for the hrefs of the two <see cref="DefinitionLocator"/>.</remarks> public int CompareTo(object obj) { DefinitionLocator other = obj as DefinitionLocator; return(this.href.CompareTo(other.href)); }
internal DefinitionLocator CreateCopyForMerging() { DefinitionLocator copy = new DefinitionLocator(); copy.CopyLocatorBaseInformation(this); if (this.childDisplayOrder != null) { copy.childDisplayOrder = new HybridDictionary(); foreach (DictionaryEntry de1 in this.childDisplayOrder) { copy.childDisplayOrder[de1.Key] = de1.Value; } } if (this.childLocatorsByHRef != null) { copy.childLocatorsByHRef = new HybridDictionary(); foreach (DictionaryEntry de1 in this.childLocatorsByHRef) { ChildDefinitionLocator cdl = de1.Value as ChildDefinitionLocator; copy.childLocatorsByHRef[de1.Key] = cdl.CreateCopyForMerging(); } } //parent info udjused later copy.parents = this.parents; return copy; }
internal void Append( DefinitionLocator arg) { if ( arg.childLocatorsByHRef != null ) { if ( this.childLocatorsByHRef == null ) { this.childLocatorsByHRef = new HybridDictionary(); this.childDisplayOrder = new HybridDictionary(); } foreach( ChildDefinitionLocator cpl in arg.childLocatorsByHRef.Values ) { ChildDefinitionLocator orig = this.childLocatorsByHRef[cpl.HRef] as ChildDefinitionLocator; if( orig == null ) { childLocatorsByHRef[cpl.HRef] = cpl; } else { foreach( DefinitionLocatorRelationshipInfo lri in cpl.LocatorRelationshipInfos ) { if ( orig.CanAddRelationship( lri )) { orig.AddRelationship(lri); } } } } } if ( arg.parents != null && arg.parents.Count > 0 ) { if ( parents == null ) { parents = arg.parents; } else { // unique parents only please foreach ( DefinitionLocator parent in arg.Parents ) { if ( !parents.Contains( parent ) ) { parents.Add( parent ); } } } } foreach ( string label in arg.labelArray ) { AddLabel( label ); } }
internal void AddParent( DefinitionLocator parent ) { if ( parents == null ) { parents = new ArrayList(); } // BUG 1610 - don't add duplicate parents if ( !parents.Contains( parent ) ) { parents.Add( parent ); } }
internal void AddChild( DefinitionLocator childPl, float orderArg, string prefLabel, string targetRole, bool? isClosed, bool? isUsable, bool? isall, bool? isScenario, bool? isDefault, bool? isRequiresElement, DimensionNode.NodeType nodeType, string priority, bool isProhibited ) { childPl.AddParent( this ); if( this.childLocatorsByHRef == null ) { this.childLocatorsByHRef = new HybridDictionary(); this.childDisplayOrder = new HybridDictionary(); } float dispOrder = orderArg; DefinitionLocatorRelationshipInfo newRelation = DefinitionLocatorRelationshipInfo.CreateObj( prefLabel, priority, orderArg,dispOrder, prefLabel, isProhibited, targetRole ,isClosed, isUsable, isall,isScenario , isRequiresElement, isDefault, nodeType ); ChildDefinitionLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildDefinitionLocator; if ( cpl == null ) { // doesn't exist in either the href table or the order table cpl = new ChildDefinitionLocator( childPl.HRef, newRelation ); childLocatorsByHRef.Add( childPl.HRef, cpl ); // keep these separate so they don't impact each other ChildDefinitionLocator cplOrder = new ChildDefinitionLocator( cpl ); } else { // the cpl already exists, append the existing relation info cpl.AddRelationship( newRelation ); } }