System.Xml.XmlTextEncoder.WriteRawWithSurrogateChecking C# (CSharp) Méthode

WriteRawWithSurrogateChecking() private méthode

private WriteRawWithSurrogateChecking ( string text ) : void
text string
Résultat void
        internal void WriteRawWithSurrogateChecking( string text ) {
            if ( text == null ) {
                return;
            }
            if ( cacheAttrValue ) {
                attrValue.Append( text );
            }

            int len = text.Length;
            int i = 0;
            char ch = (char)0;

            for (;;) {
                unsafe {
                    while ( i < len && 
                        ( ( xmlCharType.charProperties[ch = text[i]] & XmlCharType.fCharData ) != 0 // ( xmlCharType.IsCharData( ( ch = text[i] ) ) 
                        || ch < 0x20 ) ) {
                        i++;
                    }
                }
                if ( i == len ) {
                    break;
                }
                if ( (int)ch >= SurHighStart && (int)ch <= SurHighEnd ) {
                    if ( i + 1 < len ) {
                        char lowChar = text[i+1];
                        if ( lowChar >= SurLowStart && lowChar <= SurLowEnd ) {
                            i += 2;
                            continue;
                        }
                        else {
                            throw XmlConvert.CreateInvalidSurrogatePairException( lowChar, ch );
                        }
                    }
                    throw new ArgumentException( Res.GetString( Res.Xml_InvalidSurrogateMissingLowChar ) );
                }
                else if ( (int)ch >= SurLowStart && (int)ch <= SurLowEnd ) {
                    throw XmlConvert.CreateInvalidHighSurrogateCharException( ch );
                }
                else {
                    i++;
                }
            }

            textWriter.Write( text );
            return;
        }