/// <summary> /// Initializes a new instance of the <see cref="PartialJsonResultExecutor"/> class. /// </summary> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="logger">The <see cref="ILogger{PartialJsonResultExecutor}"/>.</param> /// <param name="options">The <see cref="IOptions{MvcPartialJsonOptions}"/>.</param> /// <param name="fieldsParser">The <see cref="fieldsParser"/>.</param> /// <param name="charPool">The <see cref="ArrayPool{Char}"/> for creating <see cref="T:char[]"/> buffers.</param> public PartialJsonResultExecutor(IHttpResponseStreamWriterFactory writerFactory, ILogger <PartialJsonResultExecutor> logger, IOptions <MvcPartialJsonOptions> options, IFieldsParser fieldsParser, ArrayPool <char> charPool) { if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (fieldsParser == null) { throw new ArgumentNullException(nameof(fieldsParser)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } this.WriterFactory = writerFactory; this.Logger = logger; this.Options = options.Value; this.fieldsParser = fieldsParser; this.charPool = new JsonArrayPool <char>(charPool); }
// Token: 0x060006E3 RID: 1763 RVA: 0x000076CD File Offset: 0x000058CD public static void smethod_1(IArrayPool <char> iarrayPool_0, object object_0) { if (iarrayPool_0 != null) { iarrayPool_0.Return(object_0); } }
/// <summary> /// Initializes a new <see cref="NewtonsoftJsonOutputFormatter"/> instance. /// </summary> /// <param name="serializerSettings"> /// The <see cref="JsonSerializerSettings"/>. Should be either the application-wide settings /// (<see cref="MvcNewtonsoftJsonOptions.SerializerSettings"/>) or an instance /// <see cref="JsonSerializerSettingsProvider.CreateSerializerSettings"/> initially returned. /// </param> /// <param name="charPool">The <see cref="ArrayPool{Char}"/>.</param> /// <param name="mvcOptions">The <see cref="MvcOptions"/>.</param> public NewtonsoftJsonOutputFormatter( JsonSerializerSettings serializerSettings, ArrayPool <char> charPool, MvcOptions mvcOptions) { if (serializerSettings == null) { throw new ArgumentNullException(nameof(serializerSettings)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } SerializerSettings = serializerSettings; _charPool = new JsonArrayPool <char>(charPool); _mvcOptions = mvcOptions ?? throw new ArgumentNullException(nameof(mvcOptions)); SupportedEncodings.Add(Encoding.UTF8); SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationJson); SupportedMediaTypes.Add(MediaTypeHeaderValues.TextJson); SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationAnyJsonSyntax); }
public FhirJsonOutputFormatter( FhirJsonSerializer fhirJsonSerializer, ResourceDeserializer deserializer, ILogger <FhirJsonOutputFormatter> logger, ArrayPool <char> charPool, BundleSerializer bundleSerializer) { EnsureArg.IsNotNull(fhirJsonSerializer, nameof(fhirJsonSerializer)); EnsureArg.IsNotNull(deserializer, nameof(deserializer)); EnsureArg.IsNotNull(logger, nameof(logger)); EnsureArg.IsNotNull(charPool, nameof(charPool)); EnsureArg.IsNotNull(bundleSerializer, nameof(bundleSerializer)); _fhirJsonSerializer = fhirJsonSerializer; _deserializer = deserializer; _logger = logger; _charPool = new JsonArrayPool(charPool); _bundleSerializer = bundleSerializer; SupportedEncodings.Add(Encoding.UTF8); SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(KnownContentTypes.JsonContentType); SupportedMediaTypes.Add(KnownMediaTypeHeaderValues.ApplicationJson); SupportedMediaTypes.Add(KnownMediaTypeHeaderValues.TextJson); SupportedMediaTypes.Add(KnownMediaTypeHeaderValues.ApplicationAnyJsonSyntax); }
/// <summary> /// Creates a new <see cref="NewtonsoftJsonResultExecutor"/>. /// </summary> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="logger">The <see cref="ILogger{NewtonsoftJsonResultExecutor}"/>.</param> /// <param name="mvcOptions">Accessor to <see cref="MvcOptions"/>.</param> /// <param name="jsonOptions">Accessor to <see cref="MvcNewtonsoftJsonOptions"/>.</param> /// <param name="charPool">The <see cref="ArrayPool{Char}"/> for creating <see cref="T:char[]"/> buffers.</param> public NewtonsoftJsonResultExecutor( IHttpResponseStreamWriterFactory writerFactory, ILogger <NewtonsoftJsonResultExecutor> logger, IOptions <MvcOptions> mvcOptions, IOptions <MvcNewtonsoftJsonOptions> jsonOptions, ArrayPool <char> charPool) { if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (jsonOptions == null) { throw new ArgumentNullException(nameof(jsonOptions)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } _writerFactory = writerFactory; _logger = logger; _mvcOptions = mvcOptions?.Value ?? throw new ArgumentNullException(nameof(mvcOptions)); _jsonOptions = jsonOptions.Value; _charPool = new JsonArrayPool <char>(charPool); _asyncEnumerableReaderFactory = new AsyncEnumerableReader(_mvcOptions); }
public static void ReturnBuffer(IArrayPool<char> bufferPool, char[] buffer) { if (bufferPool == null) { return; } bufferPool.Return(buffer); }
/// <summary> /// Creates a new <see cref="JsonResultExecutor"/>. /// </summary> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="logger">The <see cref="ILogger{JsonResultExecutor}"/>.</param> /// <param name="options">The <see cref="IOptions{MvcJsonOptions}"/>.</param> /// <param name="charPool">The <see cref="ArrayPool{Char}"/> for creating <see cref="T:char[]"/> buffers.</param> public JsonpResultExecutor( IHttpResponseStreamWriterFactory writerFactory, ILogger <JsonResultExecutor> logger, IOptions <MvcJsonOptions> options, ArrayPool <char> charPool) { if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } WriterFactory = writerFactory; Logger = logger; Options = options.Value; _charPool = new JsonArrayPool <char>(charPool); }
/// <summary> /// Initializes a new instance of the <see cref="PartialJsonOutputFormatter"/> class. /// </summary> /// <param name="serializerSettings"> /// The <see cref="JsonSerializerSettings"/>. Should be either the application-wide settings /// (<see cref="MvcPartialJsonOptions.SerializerSettings"/>) or an instance /// <see cref="JsonSerializerSettingsProvider.CreateSerializerSettings"/> initially returned. /// </param> /// <param name="fieldsParser">The <see cref="IFieldsParser"/>.</param> /// <param name="charPool">The <see cref="ArrayPool{Char}"/>.</param> /// <param name="options">The <see cref="MvcPartialJsonOptions"/>.</param> public PartialJsonOutputFormatter(JsonSerializerSettings serializerSettings, IFieldsParser fieldsParser, ArrayPool <char> charPool, MvcPartialJsonOptions options) { if (serializerSettings == null) { throw new ArgumentNullException(nameof(serializerSettings)); } if (fieldsParser == null) { throw new ArgumentNullException(nameof(fieldsParser)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } this.SerializerSettings = serializerSettings; this.fieldsParser = fieldsParser; this.charPool = new JsonArrayPool <char>(charPool); this.options = options; this.SupportedEncodings.Add(Encoding.UTF8); this.SupportedEncodings.Add(Encoding.Unicode); this.SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationJson); this.SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationWildcardJson); this.SupportedMediaTypes.Add(MediaTypeHeaderValues.TextJson); }
/// <summary> /// Creates a new <see cref="JsonResultExecutor"/>. /// </summary> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="logger">The <see cref="ILogger{JsonResultExecutor}"/>.</param> /// <param name="options">The <see cref="IOptions{MvcJsonOptions}"/>.</param> /// <param name="charPool">The <see cref="ArrayPool{Char}"/> for creating <see cref="T:char[]"/> buffers.</param> public JsonResultExecutor( IHttpResponseStreamWriterFactory writerFactory, ILogger<JsonResultExecutor> logger, IOptions<MvcJsonOptions> options, ArrayPool<char> charPool) { if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } WriterFactory = writerFactory; Logger = logger; Options = options.Value; _charPool = new JsonArrayPool<char>(charPool); }
// Token: 0x06000DD2 RID: 3538 RVA: 0x0005050C File Offset: 0x0004E70C public static void ReturnBuffer(IArrayPool <char> bufferPool, char[] buffer) { if (bufferPool != null) { bufferPool.Return(buffer); } }
static Pool() { _poolType = typeof(IPool <>); _pools = new Dictionary <Type, object>(); _poolHelpers = new ArrayPool <object>(1, 1, 20); _getArrayParamTypes = new Type[] { typeof(int) }; _getPoolParamTypes = new Type[0]; }
public void Append(IArrayPool <char> bufferPool, char value) { if (this._position == this._buffer.Length) { this.EnsureSize(bufferPool, 1); } this._buffer[this._position++] = value; }
public static char[] RentBuffer(IArrayPool<char> bufferPool, int minSize) { if (bufferPool == null) { return new char[minSize]; } char[] buffer = bufferPool.Rent(minSize); return buffer; }
// Token: 0x060006E2 RID: 1762 RVA: 0x000076BA File Offset: 0x000058BA public static char[] smethod_0(IArrayPool <char> iarrayPool_0, int int_0) { if (iarrayPool_0 == null) { return(new char[int_0]); } return(iarrayPool_0.Rent(int_0)); }
public TokenDataSerializer( IOptions <IdentityServiceOptions> options, ArrayPool <char> arrayPool) { _options = options.Value; _serializer = JsonSerializer.Create(_options.SerializationSettings); _pool = new JsonArrayPool(arrayPool); }
public MessageComposer(IContainer container) { serializer = container.Resolve <ISerializer>(); compression = container.Resolve <ICompression>(); encryption = container.Resolve <IEncryption>(); commandHolder = container.Resolve <ICommandHolder>(); arrayPool = container.Resolve <IArrayPool>(); }
public static char[] RentBuffer([Nullable(2)] IArrayPool <char> bufferPool, int minSize) { if (bufferPool == null) { return(new char[minSize]); } return(bufferPool.Rent(minSize)); }
/// <summary>Initializes a new instance of the <see cref="JsonMessageFormatter"/> class.</summary> public JsonMessageFormatter() { // Initialize serializer settings _defaultSerializerSettings = JsonConvertX.DefaultSettings; _defaultDeserializerSettings = JsonConvertX.DefaultDeserializerSettings; _charPool = JsonConvertX.GlobalCharacterArrayPool; }
public void Clear(IArrayPool <char> bufferPool) { if (InternalBuffer != null) { BufferUtils.ReturnBuffer(bufferPool, InternalBuffer); InternalBuffer = null; } Position = 0; }
public void Append(IArrayPool <char> bufferPool, char[] buffer, int startIndex, int count) { if (this._position + count >= (int)this._buffer.Length) { this.EnsureSize(bufferPool, count); } Array.Copy(buffer, startIndex, this._buffer, this._position, count); this._position += count; }
public void Clear(IArrayPool <char> bufferPool) { if (_buffer != null) { BufferUtils.ReturnBuffer(bufferPool, _buffer); _buffer = null; } _position = 0; }
public void Clear(IArrayPool <char> bufferPool) { if (this._buffer != null) { BufferUtils.ReturnBuffer(bufferPool, this._buffer); this._buffer = (char[])null; } this._position = 0; }
public void Clear(IArrayPool<char> bufferPool) { if (_buffer != null) { BufferUtils.ReturnBuffer(bufferPool, _buffer); _buffer = null; } _position = 0; }
private void EnsureSize(IArrayPool <char> bufferPool, int appendLength) { char[] chrArray = BufferUtils.RentBuffer(bufferPool, (this._position + appendLength) * 2); if (this._buffer != null) { Array.Copy(this._buffer, chrArray, this._position); BufferUtils.ReturnBuffer(bufferPool, this._buffer); } this._buffer = chrArray; }
public void Append(IArrayPool <char>?bufferPool, char value) { // test if the buffer array is large enough to take the value if (Position == InternalBuffer !.Length) { EnsureSize(bufferPool, 1); } // set value and increment poisition InternalBuffer ![Position++] = value;
public static char[] RentBuffer(IArrayPool <char>?bufferPool, int minSize) { if (bufferPool == null) { return(new char[minSize]); } char[] buffer = bufferPool.Rent(minSize); return(buffer); }
public void Append(IArrayPool<char> bufferPool, char[] buffer, int startIndex, int count) { if (_position + count >= _buffer.Length) { EnsureSize(bufferPool, count); } Array.Copy(buffer, startIndex, _buffer, _position, count); _position += count; }
public void Append(IArrayPool <char> bufferPool, char[] buffer, int startIndex, int count) { if (_position + count >= _buffer.Length) { EnsureSize(bufferPool, count); } Array.Copy(buffer, startIndex, _buffer, _position, count); _position += count; }
public static char[] EnsureBufferSize(IArrayPool<char> bufferPool, int size, char[] buffer) { if (bufferPool == null) { return new char[size]; } if (buffer != null) { bufferPool.Return(buffer); } return bufferPool.Rent(size); }
public void Append(IArrayPool <char> bufferPool, char value) { // test if the buffer array is large enough to take the value if (_position == _buffer.Length) { EnsureSize(bufferPool, 1); } // set value and increment poisition _buffer[_position++] = value; }
public void Append(IArrayPool<char> bufferPool, char value) { // test if the buffer array is large enough to take the value if (_position == _buffer.Length) { EnsureSize(bufferPool, 1); } // set value and increment poisition _buffer[_position++] = value; }
public void Append(IArrayPool <char> bufferPool, char[] buffer, int startIndex, int count) { if (Position + count >= InternalBuffer.Length) { EnsureSize(bufferPool, count); } Array.Copy(buffer, startIndex, InternalBuffer, Position, count); Position += count; }
/// <summary> /// Initializes a new <see cref="T:Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter" /> instance. /// </summary> /// <param name="serializerSettings"> /// The <see cref="T:Newtonsoft.Json.JsonSerializerSettings" />. Should be either the application-wide settings /// (<see cref="P:Microsoft.AspNetCore.Mvc.MvcJsonOptions.SerializerSettings" />) or an instance /// <see cref="M:Microsoft.AspNetCore.Mvc.Formatters.JsonSerializerSettingsProvider.CreateSerializerSettings" /> initially returned. /// </param> /// <param name="charPool">The <see cref="T:System.Buffers.ArrayPool`1" />.</param> public RPCJsonOutputFormatter(JsonSerializerSettings serializerSettings, ArrayPool <char> charPool) { Guard.NotNull(serializerSettings, nameof(serializerSettings)); Guard.NotNull(charPool, nameof(charPool)); this.SerializerSettings = serializerSettings; this.charPool = new JsonArrayPool <char>(charPool); this.SupportedEncodings.Add(Encoding.UTF8); this.SupportedEncodings.Add(Encoding.Unicode); this.SupportedMediaTypes.Add(ApplicationJson); this.SupportedMediaTypes.Add(TextJson); }
public static char[] EnsureBufferSize(IArrayPool <char> bufferPool, int size, char[] buffer) { if (bufferPool == null) { return(new char[size]); } if (buffer != null) { bufferPool.Return(buffer); } return(bufferPool.Rent(size)); }
private void EnsureSize(IArrayPool <char> bufferPool, int appendLength) { char[] newBuffer = BufferUtils.RentBuffer(bufferPool, (_position + appendLength) * 2); if (_buffer != null) { Array.Copy(_buffer, newBuffer, _position); BufferUtils.ReturnBuffer(bufferPool, _buffer); } _buffer = newBuffer; }
public void Append(IArrayPool <char> bufferPool, char value) { if (this._position == (int)this._buffer.Length) { this.EnsureSize(bufferPool, 1); } char[] chrArray = this._buffer; int num = this._position; this._position = num + 1; chrArray[num] = value; }
public JsonMergePatchInputFormatter( ILogger logger, JsonSerializerSettings serializerSettings, ArrayPool <char> charPool, ObjectPoolProvider objectPoolProvider) : base(logger, serializerSettings, charPool, objectPoolProvider) { this._charPool = new JsonArrayPool <char>(charPool); SupportedMediaTypes.Clear(); SupportedMediaTypes.Add(JsonMergePatchMediaType); }
public JsonOutputFormatter(JsonSerializerSettings serializerSettings, ArrayPool<char> charPool) { if (serializerSettings == null) { throw new ArgumentNullException(nameof(serializerSettings)); } if (charPool == null) { throw new ArgumentNullException(nameof(charPool)); } _serializerSettings = serializerSettings; _charPool = new JsonArrayPool<char>(charPool); SupportedEncodings.Add(Encoding.UTF8); SupportedEncodings.Add(Encoding.Unicode); SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationJson); SupportedMediaTypes.Add(MediaTypeHeaderValues.TextJson); }
public JsonInputFormatter(ILogger logger, JsonSerializerSettings serializerSettings, ArrayPool<char> charPool) { if (serializerSettings == null) { throw new ArgumentNullException(nameof(serializerSettings)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _logger = logger; _serializerSettings = serializerSettings; _charPool = new JsonArrayPool<char>(charPool); SupportedEncodings.Add(UTF8EncodingWithoutBOM); SupportedEncodings.Add(UTF16EncodingLittleEndian); SupportedMediaTypes.Add(MediaTypeHeaderValues.ApplicationJson); SupportedMediaTypes.Add(MediaTypeHeaderValues.TextJson); }
public static void WriteEscapedJavaScriptString(TextWriter writer, string s, char delimiter, bool appendDelimiters, bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, IArrayPool<char> bufferPool, ref char[] writeBuffer) { // leading delimiter if (appendDelimiters) { writer.Write(delimiter); } if (s != null) { int lastWritePosition = 0; for (int i = 0; i < s.Length; i++) { var c = s[i]; if (c < charEscapeFlags.Length && !charEscapeFlags[c]) { continue; } string escapedValue; switch (c) { case '\t': escapedValue = @"\t"; break; case '\n': escapedValue = @"\n"; break; case '\r': escapedValue = @"\r"; break; case '\f': escapedValue = @"\f"; break; case '\b': escapedValue = @"\b"; break; case '\\': escapedValue = @"\\"; break; case '\u0085': // Next Line escapedValue = @"\u0085"; break; case '\u2028': // Line Separator escapedValue = @"\u2028"; break; case '\u2029': // Paragraph Separator escapedValue = @"\u2029"; break; default: if (c < charEscapeFlags.Length || stringEscapeHandling == StringEscapeHandling.EscapeNonAscii) { if (c == '\'' && stringEscapeHandling != StringEscapeHandling.EscapeHtml) { escapedValue = @"\'"; } else if (c == '"' && stringEscapeHandling != StringEscapeHandling.EscapeHtml) { escapedValue = @"\"""; } else { if (writeBuffer == null || writeBuffer.Length < UnicodeTextLength) { writeBuffer = BufferUtils.EnsureBufferSize(bufferPool, UnicodeTextLength, writeBuffer); } StringUtils.ToCharAsUnicode(c, writeBuffer); // slightly hacky but it saves multiple conditions in if test escapedValue = EscapedUnicodeText; } } else { escapedValue = null; } break; } if (escapedValue == null) { continue; } bool isEscapedUnicodeText = string.Equals(escapedValue, EscapedUnicodeText); if (i > lastWritePosition) { int length = i - lastWritePosition + ((isEscapedUnicodeText) ? UnicodeTextLength : 0); int start = (isEscapedUnicodeText) ? UnicodeTextLength : 0; if (writeBuffer == null || writeBuffer.Length < length) { char[] newBuffer = BufferUtils.RentBuffer(bufferPool, length); // the unicode text is already in the buffer // copy it over when creating new buffer if (isEscapedUnicodeText) { Array.Copy(writeBuffer, newBuffer, UnicodeTextLength); } BufferUtils.ReturnBuffer(bufferPool, writeBuffer); writeBuffer = newBuffer; } s.CopyTo(lastWritePosition, writeBuffer, start, length - start); // write unchanged chars before writing escaped text writer.Write(writeBuffer, start, length - start); } lastWritePosition = i + 1; if (!isEscapedUnicodeText) { writer.Write(escapedValue); } else { writer.Write(writeBuffer, 0, UnicodeTextLength); } } if (lastWritePosition == 0) { // no escaped text, write entire string writer.Write(s); } else { int length = s.Length - lastWritePosition; if (writeBuffer == null || writeBuffer.Length < length) { writeBuffer = new char[length]; } s.CopyTo(lastWritePosition, writeBuffer, 0, length); // write remaining text writer.Write(writeBuffer, 0, length); } } // trailing delimiter if (appendDelimiters) { writer.Write(delimiter); } }
private void EnsureSize(IArrayPool<char> bufferPool, int appendLength) { char[] newBuffer = BufferUtils.RentBuffer(bufferPool, (_position + appendLength) * 2); if (_buffer != null) { Array.Copy(_buffer, newBuffer, _position); BufferUtils.ReturnBuffer(bufferPool, _buffer); } _buffer = newBuffer; }
public StorageAccess( IPool pool, IArrayPool arrayPool, IAssetManagerProvider assetManagerProvider) { this.m_Pool = pool; this.m_ArrayPool = arrayPool; this.m_AssetManagerProvider = assetManagerProvider; }
/// <summary> /// Creates a new runtime layer that holds the specified algorithm. /// </summary> public RuntimeLayer( IPool pool, IArrayPool arrayPool, IAlgorithm algorithm, IAssetManagerProvider assetManagerProvider) { if (algorithm == null) throw new ArgumentNullException("algorithm"); this.m_Pool = pool; this.m_ArrayPool = arrayPool; this.m_Algorithm = algorithm; var inputs = new List<RuntimeLayer>(); for (var i = 0; i < algorithm.InputTypes.Length; i++) inputs.Add(null); this.m_Inputs = inputs.ToArray(); this.Seed = 0; this.Modifier = 0; this.AssetManager = assetManagerProvider.GetAssetManager(); }
public StringBuffer(IArrayPool<char> bufferPool, int initalSize) : this(BufferUtils.RentBuffer(bufferPool, initalSize)) { }