Пример #1
0
        public void TestCanAddRelationship()
        {
            LocatorRelationshipInfo  lri  = LocatorRelationshipInfo.CreateObj("label", "1", 1F, 1F, "pref label", "1", false);
            LocatorRelationshipInfo  lri2 = LocatorRelationshipInfo.CreateObj("label", "2", 1F, 1F, "pref label", "1", false);
            ChildPresentationLocator cpl  = new ChildPresentationLocator("href1", lri);

            Assert.IsFalse(cpl.CanAddRelationship(lri), "can add dup");
            Assert.IsTrue(cpl.CanAddRelationship(lri2), "can't add new val");
        }
Пример #2
0
        public void AddChild( PresentationLocator childPl, string label,  string priority,
			float orderArg,  string prefLabel, string weight, bool isProhibited )
        {
            childPl.AddParent( this );

            if( this.childLocatorsByHRef == null )
            {
                this.childLocatorsByHRef = new HybridDictionary();
                this.childDisplayOrder = new HybridDictionary();
            }

            LocatorRelationshipInfo newRelation = LocatorRelationshipInfo.CreateObj( label,
                priority, orderArg, orderArg, prefLabel, weight, isProhibited);
            ChildPresentationLocator cpl = childLocatorsByHRef[childPl.HRef] as ChildPresentationLocator;

            if ( cpl == null )
            {
                // doesn't exist in either the href table or the order table
                cpl = new ChildPresentationLocator( childPl.HRef, newRelation );

                childLocatorsByHRef.Add( childPl.HRef, cpl );

                // keep these separate so they don't impact each other
                ChildPresentationLocator cplOrder = new ChildPresentationLocator( cpl );

            }
            else
            {
                // the cpl already exists, append the existing relation info
                cpl.AddRelationship( newRelation );

            }
        }
Пример #3
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;
        }
        public void TestCanAddRelationship()
        {
            LocatorRelationshipInfo lri = LocatorRelationshipInfo.CreateObj( "label", "1", 1F,1F, "pref label", "1", false );
            LocatorRelationshipInfo lri2 = LocatorRelationshipInfo.CreateObj( "label", "2", 1F,1F, "pref label", "1", false );
            ChildPresentationLocator cpl = new ChildPresentationLocator( "href1", lri );

            Assert.IsFalse( cpl.CanAddRelationship( lri ), "can add dup" );
            Assert.IsTrue( cpl.CanAddRelationship( lri2 ), "can't add new val" );
        }