System.Runtime.Serialization.XmlObjectSerializer.WriteRootElement C# (CSharp) Method

WriteRootElement() private method

private WriteRootElement ( System.Runtime.Serialization.XmlWriterDelegator writer, System.Runtime.Serialization.DataContract contract, XmlDictionaryString name, XmlDictionaryString ns, bool needsContractNsAtRoot ) : void
writer System.Runtime.Serialization.XmlWriterDelegator
contract System.Runtime.Serialization.DataContract
name System.Xml.XmlDictionaryString
ns System.Xml.XmlDictionaryString
needsContractNsAtRoot bool
return void
        internal void WriteRootElement(XmlWriterDelegator writer, DataContract contract, XmlDictionaryString name, XmlDictionaryString ns, bool needsContractNsAtRoot)
        {
            if (name == null) // root name not set explicitly
            {
                if (!contract.HasRoot)
                    return;
                contract.WriteRootElement(writer, contract.TopLevelElementName, contract.TopLevelElementNamespace);
            }
            else
            {
                contract.WriteRootElement(writer, name, ns);
                if (needsContractNsAtRoot)
                {
                    writer.WriteNamespaceDecl(contract.Namespace);
                }
            }
        }