private PSStyle() { Formatting = new FormattingData(); Progress = new ProgressConfiguration(); Foreground = new ForegroundColor(); Background = new BackgroundColor(); }
// Sets up cultures with digits represented by 1 or 5 'A's (0) through 1 or 5 'J's (9) and the minus sigh represented by an underscore followed by a question mark static CustomCultureTests() { byte[][] utf16digitsAndSymbols = new byte[17][]; for (ushort digit = 0; digit < 10; digit++) { char digitChar = (char)(digit + 'A'); var digitString = new string(digitChar, 5); utf16digitsAndSymbols[digit] = GetBytesUtf16(digitString); } utf16digitsAndSymbols[(ushort)FormattingData.Symbol.DecimalSeparator] = GetBytesUtf16("."); utf16digitsAndSymbols[(ushort)FormattingData.Symbol.GroupSeparator] = GetBytesUtf16(","); utf16digitsAndSymbols[(ushort)FormattingData.Symbol.MinusSign] = GetBytesUtf16("_?"); Culture5 = new FormattingData(utf16digitsAndSymbols, FormattingData.Encoding.Utf16); utf16digitsAndSymbols = new byte[17][]; for (ushort digit = 0; digit < 10; digit++) { char digitChar = (char)(digit + 'A'); var digitString = new string(digitChar, 1); utf16digitsAndSymbols[digit] = GetBytesUtf16(digitString); } utf16digitsAndSymbols[(ushort)FormattingData.Symbol.DecimalSeparator] = GetBytesUtf16("."); utf16digitsAndSymbols[(ushort)FormattingData.Symbol.GroupSeparator] = GetBytesUtf16(","); utf16digitsAndSymbols[(ushort)FormattingData.Symbol.MinusSign] = GetBytesUtf16("_?"); Culture1 = new FormattingData(utf16digitsAndSymbols, FormattingData.Encoding.Utf16); }
public override string GetPluralName(string isoCode, string pluralKey) { StandardPlural?plural = StandardPluralUtil.OrNullFromString(pluralKey); string[] pluralsData = FetchPluralsData(isoCode); // See http://unicode.org/reports/tr35/#Currencies, especially the fallback rule. string result = null; if (plural != null) { result = pluralsData[1 + (int)plural]; } if (result == null && fallback) { // First fall back to the "other" plural variant // Note: If plural is already "other", this fallback is benign result = pluralsData[1 + (int)StandardPlural.Other]; } if (result == null && fallback) { // If that fails, fall back to the display name FormattingData formattingData = FetchFormattingData(isoCode); result = formattingData.displayName; } if (result == null && fallback) { // If all else fails, return the ISO code result = isoCode; } return(result); }
public override string GetSymbol(string isoCode) { FormattingData formattingData = FetchFormattingData(isoCode); // Fall back to ISO Code if (formattingData.symbol == null && fallback) { return(isoCode); } return(formattingData.symbol); }
public override string GetName(string isoCode) { FormattingData formattingData = FetchFormattingData(isoCode); // Fall back to ISO Code if (formattingData.displayName == null && fallback) { return(isoCode); } return(formattingData.displayName); }
public BufferFormatter(int capacity, FormattingData formattingData, ArrayPool<byte> pool = null) { _formattingData = formattingData; _count = 0; _pool = pool; if(_pool == null) { _pool = ArrayPool<byte>.Shared; } _buffer = _pool.Rent(capacity); }
public StreamFormatter(Stream stream, FormattingData formattingData, ArrayPool<byte> pool, int bufferSize = 256) { _pool = pool; _buffer = null; if (bufferSize > 0) { _buffer = _pool.Rent(bufferSize); } _formattingData = formattingData; _stream = stream; }
public bool TryFormat(Span <byte> buffer, Format.Parsed format, FormattingData formattingData, out int written) { if (buffer.Length < _bytes.Length) { written = 0; return(false); } // TODO: this needs to check if formattingData is utf8 buffer.Set(_bytes); written = _bytes.Length; return(true); }
///////////////////////////////////////////// /// END PUBLIC API -- START DATA FRONTEND /// ///////////////////////////////////////////// internal FormattingData FetchFormattingData(string isoCode) { FormattingData result = formattingDataCache; if (result == null || !result.isoCode.Equals(isoCode)) { result = new FormattingData(isoCode); CurrencySink sink = new CurrencySink(!fallback, CurrencySink.EntrypointTable.CURRENCIES); sink.formattingData = result; rb.GetAllItemsWithFallbackNoFail("Currencies/" + isoCode, sink); formattingDataCache = result; } return(result); }
public bool TryFormat(Span <byte> buffer, Format.Parsed format, FormattingData formattingData, out int bytesWritten) { if (!PrimitiveFormatters.TryFormat(_age, buffer, format, formattingData, out bytesWritten)) { return(false); } char symbol = _inMonths ? 'm' : 'y'; int symbolBytes; if (!PrimitiveFormatters.TryFormat(symbol, buffer.Slice(bytesWritten), format, formattingData, out symbolBytes)) { return(false); } bytesWritten += symbolBytes; return(true); }
public HttpHeaderBuffer(Span <byte> bytes, FormattingData formattingData) { _bytes = bytes; _formattingData = formattingData; }
public static WriteableBufferFormatter GetFormatter(this IWritableChannel channel, FormattingData formattingData) { var buffer = channel.Alloc(2048); return(new WriteableBufferFormatter(ref buffer, formattingData)); }
public WriteableBufferFormatter(ref WritableBuffer writableBuffer, FormattingData formattingData) { _writableBuffer = writableBuffer; FormattingData = formattingData; }
public override CurrencyFormatInfo GetFormatInfo(string isoCode) { FormattingData formattingData = FetchFormattingData(isoCode); return(formattingData.formatInfo); }
private PSStyle() { Formatting = new FormattingData(); Foreground = new ForegroundColor(); Background = new BackgroundColor(); }
public HttpHeaderBuffer(Span <byte> valueByteSpan, FormattingData formattingData) { _valueByteSpan = valueByteSpan; _formattingData = formattingData; }