System.Xml.XmlUtf8RawTextWriter.ValidateContentChars C# (CSharp) Méthode

ValidateContentChars() protected méthode

protected ValidateContentChars ( string chars, string propertyName, bool allowOnlyWhitespace ) : void
chars string
propertyName string
allowOnlyWhitespace bool
Résultat void
        protected unsafe void ValidateContentChars( string chars, string propertyName, bool allowOnlyWhitespace ) {
            if ( allowOnlyWhitespace ) {
                if ( !xmlCharType.IsOnlyWhitespace( chars ) ) {
                    throw new ArgumentException( Res.GetString( Res.Xml_IndentCharsNotWhitespace, propertyName ) );
                }
            }
            else {
                string error = null;
                for ( int i = 0; i < chars.Length; i++ ) {
                    if ( !xmlCharType.IsTextChar( chars[i] ) ) {
                        switch ( chars[i] ) {
                            case '\n':
                            case '\r':
                            case '\t':
                                continue;
                            case '<':
                            case '&':
                            case ']':
                                error = Res.GetString( Res.Xml_InvalidCharacter, XmlException.BuildCharExceptionStr( chars[i] ) );
                                goto Error;
                            default:
                                if ( (int)chars[i] >= SurHighStart && (int)chars[i] <= SurHighEnd ) {
                                    if ( i + 1 < chars.Length ) {
                                        if ( (int)chars[i+1] >= SurLowStart && (int)chars[i+1] <= SurLowEnd  ) {
                                            i++;
                                            continue;
                                        }
                                    }
                                    error = Res.GetString( Res.Xml_InvalidSurrogateMissingLowChar );
                                    goto Error;
                                }
                                else if ( (int)chars[i] >= SurLowStart && (int)chars[i] <= SurLowEnd ) {
                                    error = Res.GetString( Res.Xml_InvalidSurrogateHighChar, ((uint)chars[i]).ToString( "X", CultureInfo.InvariantCulture ) );
                                    goto Error;
                                }
                                continue;
                        }
                    }
                }
                return;

            Error:
                throw new ArgumentException( Res.GetString( Res.Xml_InvalidCharsInIndent, new string[] { propertyName, error } ) );
            }
        }
    }