System.Xml.XPath.XPathNavigator.SetTypedValue C# (CSharp) Method

SetTypedValue() public method

public SetTypedValue ( object typedValue ) : void
typedValue object
return void
        public virtual void SetTypedValue(object typedValue)
        {
            if (typedValue == null)
            {
                throw new ArgumentNullException(nameof(typedValue));
            }
            switch (NodeType)
            {
                case XPathNodeType.Element:
                case XPathNodeType.Attribute:
                    break;
                default:
                    throw new InvalidOperationException(SR.Xpn_BadPosition);
            }
            string value = null;
            IXmlSchemaInfo schemaInfo = SchemaInfo;
            if (schemaInfo != null)
            {
                XmlSchemaType schemaType = schemaInfo.SchemaType;
                if (schemaType != null)
                {
                    value = schemaType.ValueConverter.ToString(typedValue, this);
                    XmlSchemaDatatype datatype = schemaType.Datatype;
                    if (datatype != null)
                    {
                        datatype.ParseValue(value, NameTable, this);
                    }
                }
            }
            if (value == null)
            {
                value = XmlUntypedConverter.Untyped.ToString(typedValue, this);
            }
            SetValue(value);
        }