/// <summary> /// Sets the value of this field /// </summary> /// <param name="id"></param> /// <param name="value"></param> /// <returns></returns> public override SimpleField SetField(IElementDef id, SifSimpleType value) { // verify the parameter values if (id == null || !(CommonDTD.PARTIALDATETYPE.Name.Equals(id.Name))) { throw new ArgumentException("ElementDef must be CommonDTD.PARTIALDATETYPE"); } if (value != null && value.DataType != SifDataType.String) { throw new ArgumentException("Value type must be SIFDataType.STRING"); } // Allow any datatype to be set, but convert it to a string // This is important, because the value of this could be set to // an int from mappings, because it was an int in SIF 1.5 if (value != null && value.DataType != SifDataType.String) { value = new SifString(value.ToString()); } // Parse the text value into its representative parts SimpleField returnValue = base.SetField(id, value); parseTextValue(); return(returnValue); }
private void assertByXPath(SifXPathContext context, String xPath, String assertedValue) { Element e = (Element)context.GetValue(xPath); Assertion.AssertNotNull("Field is null for path " + xPath, e); SifSimpleType value = e.SifValue; Assertion.AssertNotNull("Value is null for path " + xPath, value); Assertion.AssertEquals(xPath, assertedValue, value.ToString()); }
/// <summary> /// Sets the value to the underlying dictionary using a SifFormatter /// </summary> /// <param name="value"></param> /// <returns></returns> protected override Object ToMapValue(SifSimpleType value) { // Store items in the map using a string value return(value.ToString(fDataFormatter)); }