System.Xml.XmlTextWriter.ValidateName C# (CSharp) Method

ValidateName() private method

private ValidateName ( string name, bool NCName ) : void
name string
NCName bool
return void
        private unsafe void ValidateName(string name, bool NCName) {
            if (name == null || name.Length == 0) {
                throw new ArgumentException(Res.GetString(Res.Xml_EmptyName));
            }
            int nameLength = name.Length;
            int position   = 0;
            int colonPosition = -1;

            if (namespaces) {
                if ((xmlCharType.charProperties[name[position]] & XmlCharType.fNCStartName) != 0) { // if (xmlCharType.IsStartNCNameChar(name[position])) {
            Continue:
                    position ++;
                    while (position < nameLength && 
                        (xmlCharType.charProperties[name[position]] & XmlCharType.fNCName) != 0) { // xmlCharType.IsNCNameChar(name[position])) {
                        position ++;
                    }
                    if (position == nameLength) {
                        return;
                    }
                    if (name[position] == ':') {
                        if (!NCName) {
                            if (colonPosition == -1) {
                                if (position + 1 < nameLength) {
                                    colonPosition = position;
                                    // We should check if the character after ':' is a valid start name 
                                    // character but we can't do that because of backward compatilibity
                                    goto Continue;
                                }
                            }
                        }
                    }
                }
            }
            else {
                if ((xmlCharType.charProperties[name[0]] & XmlCharType.fNCStartName) != 0 || name[0] == ':') { // if (xmlCharType.IsStartNameChar(name[0])) {
                    position ++;
                    while (position < nameLength && 
                        ((xmlCharType.charProperties[name[position]] & XmlCharType.fNCName) != 0 || name[position] == ':')) { // xmlCharType.IsNameChar(name[position])) {
                        position ++;
                    }
                    if (position == nameLength) {
                        return;
                    }
                }
            }
            throw new ArgumentException(Res.GetString(Res.Xml_InvalidNameChars, name));
        }