Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ StartAttribute()

void System.Xml.XmlBaseWriter.StartAttribute ( [AllowNull] ref string prefix,
string localName,
string ns,
XmlDictionaryString xNs )
inlineprivateinherited

Definition at line 882 of file XmlBaseWriter.cs.

883 {
884 if (IsClosed)
885 {
886 ThrowClosed();
887 }
888 if (_writeState == WriteState.Attribute)
889 {
891 }
892 if (localName == null || (localName.Length == 0 && prefix != "xmlns"))
893 {
894 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("localName"));
895 }
896 if (_writeState != WriteState.Element)
897 {
899 }
900 if (prefix == null)
901 {
902 if (ns == "http://www.w3.org/2000/xmlns/" && localName != "xmlns")
903 {
904 prefix = "xmlns";
905 }
906 else if (ns == "http://www.w3.org/XML/1998/namespace")
907 {
908 prefix = "xml";
909 }
910 else
911 {
912 prefix = string.Empty;
913 }
914 }
915 if (prefix.Length == 0 && localName == "xmlns")
916 {
917 prefix = "xmlns";
918 localName = string.Empty;
919 }
920 _isXmlnsAttribute = false;
921 _isXmlAttribute = false;
922 if (prefix == "xml")
923 {
924 if (ns != null && ns != "http://www.w3.org/XML/1998/namespace")
925 {
926 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.SR.Format(System.SR.XmlPrefixBoundToNamespace, "xml", "http://www.w3.org/XML/1998/namespace", ns), "ns"));
927 }
928 _isXmlAttribute = true;
929 _attributeValue = string.Empty;
930 _attributeLocalName = localName;
931 }
932 else if (prefix == "xmlns")
933 {
934 if (ns != null && ns != "http://www.w3.org/2000/xmlns/")
935 {
936 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.SR.Format(System.SR.XmlPrefixBoundToNamespace, "xmlns", "http://www.w3.org/2000/xmlns/", ns), "ns"));
937 }
938 _isXmlnsAttribute = true;
939 _attributeValue = string.Empty;
940 _attributeLocalName = localName;
941 }
942 else if (ns == null)
943 {
944 if (prefix.Length == 0)
945 {
946 ns = string.Empty;
947 }
948 else
949 {
951 if (ns == null)
952 {
954 }
955 }
956 }
957 else if (ns.Length == 0)
958 {
959 if (prefix.Length != 0)
960 {
962 }
963 }
964 else if (prefix.Length == 0)
965 {
966 string text = _nsMgr.LookupAttributePrefix(ns);
967 if (text == null)
968 {
969 if (ns.Length == "http://www.w3.org/2000/xmlns/".Length && ns == "http://www.w3.org/2000/xmlns/")
970 {
972 }
973 if (ns.Length == "http://www.w3.org/XML/1998/namespace".Length && ns == "http://www.w3.org/XML/1998/namespace")
974 {
976 }
977 text = GeneratePrefix(ns, xNs);
978 }
979 prefix = text;
980 }
981 else
982 {
984 }
985 _writeState = WriteState.Attribute;
986 }
static string XmlSpecificBindingNamespace
Definition SR.cs:494
static string XmlEmptyNamespaceRequiresNullPrefix
Definition SR.cs:378
static string XmlUndefinedPrefix
Definition SR.cs:506
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlInvalidWriteState
Definition SR.cs:450
static string XmlPrefixBoundToNamespace
Definition SR.cs:486
Definition SR.cs:7
void AddNamespaceIfNotDeclared(string prefix, string uri, XmlDictionaryString uriDictionaryString)
override void WriteEndAttribute()
readonly NamespaceManager _nsMgr
string GeneratePrefix(string ns, XmlDictionaryString xNs)

References System.Xml.XmlBaseWriter._attributeLocalName, System.Xml.XmlBaseWriter._attributeValue, System.Xml.XmlBaseWriter._isXmlAttribute, System.Xml.XmlBaseWriter._isXmlnsAttribute, System.Xml.XmlBaseWriter._nsMgr, System.Xml.XmlBaseWriter._writeState, System.Xml.XmlBaseWriter.NamespaceManager.AddNamespaceIfNotDeclared(), System.Xml.ArgumentException, System.Xml.Dictionary, System.SR.Format(), System.Xml.XmlBaseWriter.GeneratePrefix(), System.Xml.XmlBaseWriter.IsClosed, System.Xml.XmlBaseWriter.NamespaceManager.LookupAttributePrefix(), System.Xml.XmlBaseWriter.NamespaceManager.LookupNamespace(), System.prefix, System.text, System.Xml.XmlBaseWriter.ThrowClosed(), System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), System.Xml.XmlBaseWriter.WriteEndAttribute(), System.SR.XmlEmptyNamespaceRequiresNullPrefix, System.SR.XmlInvalidWriteState, System.SR.XmlPrefixBoundToNamespace, System.SR.XmlSpecificBindingNamespace, and System.SR.XmlUndefinedPrefix.

Referenced by System.Xml.XmlBaseWriter.WriteStartAttribute(), and System.Xml.XmlBaseWriter.WriteStartAttribute().