internal void Write( char ch ) {
if ( cacheAttrValue ) {
attrValue.Append( ch );
}
bool isAttrValue;
unsafe {
isAttrValue = ( xmlCharType.charProperties[ch] & XmlCharType.fAttrValue ) != 0; // xmlCharType.IsAttributeValueChar( ch )
}
if ( isAttrValue ) {
textWriter.Write( ch );
}
else {
switch ( ch ) {
case (char)0x9:
textWriter.Write( ch );
break;
case (char)0xA:
case (char)0xD:
if ( inAttribute ) {
WriteCharEntityImpl( ch );
}
else {
textWriter.Write( ch );
}
break;
case '<':
WriteEntityRefImpl( "lt" );
break;
case '>':
WriteEntityRefImpl( "gt" );
break;
case '&':
WriteEntityRefImpl( "amp" );
break;
case '\'':
if ( inAttribute && quoteChar == ch ) {
WriteEntityRefImpl( "apos" );
}
else {
textWriter.Write( '\'' );
}
break;
case '"':
if ( inAttribute && quoteChar == ch ) {
WriteEntityRefImpl( "quot" );
}
else {
textWriter.Write( '"' );
}
break;
default:
if ( (int)ch >= SurHighStart && (int)ch <= SurHighEnd ) {
throw new ArgumentException( Res.GetString( Res.Xml_InvalidSurrogateMissingLowChar ) );
}
else if ( (int)ch >= SurLowStart && (int)ch <= SurLowEnd ) {
throw XmlConvert.CreateInvalidHighSurrogateCharException( ch );
}
else {
Debug.Assert( ( ch < 0x20 && !xmlCharType.IsWhiteSpace( ch ) ) || ( ch > 0xFFFD ) );
WriteCharEntityImpl( ch );
}
break;
}
}
}