Пример #1
0
        public void Append(PresentationLocator arg)
        {
            if (arg.childLocatorsByHRef != null)
            {
                if (this.childLocatorsByHRef == null)
                {
                    this.childLocatorsByHRef = new HybridDictionary();
                    this.childDisplayOrder   = new HybridDictionary();
                }

                foreach (ChildPresentationLocator cpl in arg.childLocatorsByHRef.Values)
                {
                    ChildPresentationLocator orig = this.childLocatorsByHRef[cpl.HRef] as ChildPresentationLocator;

                    if (orig == null)
                    {
                        childLocatorsByHRef[cpl.HRef] = cpl;
                    }
                    else
                    {
                        foreach (LocatorRelationshipInfo 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 (PresentationLocator parent in arg.Parents)
                    {
                        if (!parents.Contains(parent))
                        {
                            parents.Add(parent);
                        }
                    }
                }
            }

            foreach (string label in arg.labelArray)
            {
                AddLabel(label);
            }
        }
Пример #2
0
        /// <summary>
        /// Add a new relationship between two locators...
        /// </summary>
        /// <param name="elementId"></param>
        /// <param name="parentElementId"></param>
        /// <param name="newLocatorRelationshipInfo"></param>
        /// <param name="taxonomy"></param>
        /// <returns></returns>
        public bool UpdateArc(string elementId, string parentElementId,
                              LocatorRelationshipInfo newLocatorRelationshipInfo, Taxonomy taxonomy)
        {
            PresentationLocator parentLocator = locators[parentElementId] as PresentationLocator;


            if (parentLocator == null && !string.IsNullOrEmpty(parentElementId))
            {
                parentLocator           = new PresentationLocator();
                parentLocator.href      = parentElementId;
                parentLocator.MyElement = taxonomy.allElements[parentElementId] as Element;

                locators[parentElementId] = parentLocator;
            }

            PresentationLocator childLocator = locators[elementId] as PresentationLocator;

            if (childLocator == null)
            {
                childLocator           = new PresentationLocator();
                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();
                }
                ChildPresentationLocator cpl = parentLocator.childLocatorsByHRef[elementId] as ChildPresentationLocator;
                if (cpl != null)
                {
                    cpl.AddRelationship(newLocatorRelationshipInfo);
                }
                else
                {
                    cpl = new ChildPresentationLocator(elementId, newLocatorRelationshipInfo);
                    parentLocator.childLocatorsByHRef[elementId] = cpl;
                }
            }



            return(true);
        }