private object PerThreadJavaCoder(int index) { var elem = perThreadJavaCodersMap.get(this); if (elem == null) { var elemNew = new java.util.concurrent.atomic.AtomicReferenceArray(2); elem = perThreadJavaCodersMap.putIfAbsent(this, elemNew) ?? elemNew; } var coders = (java.util.concurrent.atomic.AtomicReferenceArray)elem; elem = coders.get(index); if (elem == null) { var elemNew = (index == 0) ? (object)JavaCharset.newDecoder() .onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE) .onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE) : (object)JavaCharset.newEncoder() .onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE) .onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE); elem = coders.getAndSet(index, elemNew) ?? elemNew; } return(elem); }
/// <summary> /// Constructs a new OutputStreamWriter using /// <code>out</code> /// as the target /// stream to write converted characters to and /// <code>cs</code> /// as the character /// encoding. /// </summary> /// <param name="out">the target stream to write converted bytes to.</param> /// <param name="cs"> /// the /// <code>Charset</code> /// that specifies the character encoding. /// </param> public OutputStreamWriter(java.io.OutputStream @out, java.nio.charset.Charset cs) : base(@out) { this.@out = @out; encoder = cs.newEncoder(); encoder.onMalformedInput(java.nio.charset.CodingErrorAction.REPLACE); encoder.onUnmappableCharacter(java.nio.charset.CodingErrorAction.REPLACE); }