/** * Sets an array of <code>SIF_ExtendedElement</code> objects. All existing * <code>SIF_ExtendedElement</code> instances * are removed and replaced with this list. Calling this method with the * parameter value set to null removes all <code>SIF_ExtendedElements</code>. * @param elements The SIF_Extended elements instances to set on this object * * @since ADK 1.5 */ //public void SetSifExtendedElements(SIF_ExtendedElement[] elements) //{ // SIF_ExtendedElements = elements; //} /// <summary> Sets a SIF_ExtendedElement.</summary> /// <param name="name">The element name /// </param> /// <param name="valu">The element value /// /// @since Adk 1.5 /// </param> public virtual void AddSIFExtendedElement(string name, string valu) { if (GlobalDTD.SIF_EXTENDEDELEMENTS == null || name == null || valu == null) { return; } SIF_ExtendedElement ele = null; // Lookup existing SIF_ExtendedElements container SIF_ExtendedElements see = (SIF_ExtendedElements)GetChild(GlobalDTD.SIF_EXTENDEDELEMENTS); if (see == null) { // Create a new SIF_ExtendedElements container see = new SIF_ExtendedElements(); AddChild(see); } else { // Lookup existing SIF_ExtendedElement with this name ele = see[name]; } // Create/update SIF_ExtendedElement if (ele == null) { ele = new SIF_ExtendedElement(name, valu); see.AddChild(ele); } else { ele.TextValue = valu; } }
public void testExtendedElements() { StudentPersonal sp = new StudentPersonal(); SIF_ExtendedElements container = sp.SIFExtendedElementsContainer; container.SetChildren(new SIF_ExtendedElement[] { new SIF_ExtendedElement("key1", "value1") }); container.SetChildren(new SIF_ExtendedElement[] { new SIF_ExtendedElement("key1", "value1") }); Assert.AreEqual(1, sp.SIFExtendedElements.Length, "Result should be 1"); }
/// <summary> Gets the SIF_ExtendedElement with the specified Name attribute.</summary> /// <param name="name">The value of the SIF_ExtendedElement/@Name attribute to search for /// </param> /// <returns> The SIF_ExtendedElement that has a Name attribute matching the /// <c>name</c> parameter, or null if no such element exists /// <since>ADK 1.5</since> /// </returns> public virtual SIF_ExtendedElement GetSIFExtendedElement(string name) { if (GlobalDTD.SIF_EXTENDEDELEMENTS == null || name == null) { return(null); } SIF_ExtendedElements container = (SIF_ExtendedElements)GetChild(GlobalDTD.SIF_EXTENDEDELEMENTS); if (container == null) { return(null); } return(container[name]); }
public void testSetSIF_ExtendedElementsContainer() { StudentPersonal sp = ObjectCreator.CreateStudentPersonal(); SIF_ExtendedElements elements = new SIF_ExtendedElements(); elements.AddSIF_ExtendedElement("urn:foo", "bar"); // Add another one with the same key elements.AddSIF_ExtendedElement("urn:foo", "bar2"); // Add a third one with a different key elements.AddSIF_ExtendedElement("urn:foo2", "bar3"); sp.SIFExtendedElementsContainer = elements; SIF_ExtendedElement[] elementArray = sp.SIFExtendedElementsContainer.ToArray(); Assert.AreEqual(3, elementArray.Length, "Should have three items in it."); // Try to find all three elements to make sure that they are all there bool found1 = false, found2 = false, found3 = false; for (int i = 0; i < 3; i++) { SIF_ExtendedElement test = elementArray[i]; String key = test.Key; if (key.Equals("urn:foo")) { String value = test.TextValue; if (value.Equals("bar")) { found1 = true; } else if (value.Equals("bar2")) { found2 = true; } } else { found3 = key.Equals("urn:foo2") && test.TextValue.Equals("bar3"); } } Assert.IsTrue(found1, "Element1 was not found"); Assert.IsTrue(found2, "Element2 was not found"); Assert.IsTrue(found3, "Element3 was not found"); }
//* Sets the SIF_ExtendedElements container for this object.<P> //* Normally, agents can just call {@link #addSIFExtendedElement(String, String)}, //* which automatically creates a SIF_ExtendedElements container, if necessary and //* allows for easy addition of SIF_ExtendedElements.<p> //* This method is provided as a convenience to agents that need more control or //* wish to set or completely replace the existing SIF_ExtendedElements container. public void AddSifExtendedElementsContainer(SIF_ExtendedElements container) { RemoveChild(GlobalDTD.SIF_EXTENDEDELEMENTS); AddChild(container); }
//* Sets the SIF_ExtendedElements container for this object.<P> //* Normally, agents can just call {@link #addSIFExtendedElement(String, String)}, //* which automatically creates a SIF_ExtendedElements container, if necessary and //* allows for easy addition of SIF_ExtendedElements.<p> //* This method is provided as a convenience to agents that need more control or //* wish to set or completely replace the existing SIF_ExtendedElements container. public void AddSifExtendedElementsContainer( SIF_ExtendedElements container ) { RemoveChild( GlobalDTD.SIF_EXTENDEDELEMENTS ); AddChild( container ); }
/** * Sets an array of <code>SIF_ExtendedElement</code> objects. All existing * <code>SIF_ExtendedElement</code> instances * are removed and replaced with this list. Calling this method with the * parameter value set to null removes all <code>SIF_ExtendedElements</code>. * @param elements The SIF_Extended elements instances to set on this object * * @since ADK 1.5 */ //public void SetSifExtendedElements(SIF_ExtendedElement[] elements) //{ // SIF_ExtendedElements = elements; //} /// <summary> Sets a SIF_ExtendedElement.</summary> /// <param name="name">The element name /// </param> /// <param name="valu">The element value /// /// @since Adk 1.5 /// </param> public virtual void AddSIFExtendedElement( string name, string valu ) { if ( GlobalDTD.SIF_EXTENDEDELEMENTS == null || name == null || valu == null ) { return; } SIF_ExtendedElement ele = null; // Lookup existing SIF_ExtendedElements container SIF_ExtendedElements see = (SIF_ExtendedElements) GetChild( GlobalDTD.SIF_EXTENDEDELEMENTS ); if ( see == null ) { // Create a new SIF_ExtendedElements container see = new SIF_ExtendedElements(); AddChild( see ); } else { // Lookup existing SIF_ExtendedElement with this name ele = see[name]; } // Create/update SIF_ExtendedElement if ( ele == null ) { ele = new SIF_ExtendedElement( name, valu ); see.AddChild( ele ); } else { ele.TextValue = valu; } }