##// END OF EJS Templates
Fixed promise rejection when there is not specified error handler in the reaction....
Fixed promise rejection when there is not specified error handler in the reaction. FIXED SPELLING IN THE XML CONTAINER CONFIGURATION signleton->singleton Code cleanup Update tests make them working on dotnet core

File last commit:

r295:28af686e24f7 default
r295:28af686e24f7 default
Show More
StringTranslator.cs
46 lines | 1.7 KiB | text/x-csharp | CSharpLexer
/ Implab / src / Formats / Json / StringTranslator.cs
cin
Fixed promise rejection when there is not specified error handler in the reaction....
r295 using System.Diagnostics;
cin
Added tests for Implab.ServiceHost.Unity configuration loader.
r289 using System.Linq;
namespace Implab.Formats.Json {
/// <summary>
/// Класс для преобразования экранированной строки JSON
/// </summary>
static class StringTranslator {
static readonly char[] _escMap;
static readonly int[] _hexMap;
static StringTranslator() {
var chars = new char[] { 'b', 'f', 't', 'r', 'n', '\\', '/', '"' };
var vals = new char[] { '\b', '\f', '\t', '\r', '\n', '\\', '/', '"' };
_escMap = new char[chars.Max() + 1];
for (int i = 0; i < chars.Length; i++)
_escMap[chars[i]] = vals[i];
var hexs = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F' };
var ints = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15 };
_hexMap = new int[hexs.Max() + 1];
for (int i = 0; i < hexs.Length; i++)
_hexMap[hexs[i]] = ints[i];
}
internal static char TranslateEscapedChar(char symbol) {
return _escMap[symbol];
}
internal static char TranslateHexUnicode(char[] symbols, int offset) {
Debug.Assert(symbols != null);
Debug.Assert(symbols.Length - offset >= 4);
int value = (_hexMap[symbols[offset]] << 12)
| (_hexMap[symbols[offset + 1]] << 8)
| (_hexMap[symbols[offset + 2]] << 4)
| (_hexMap[symbols[offset + 3]]);
return (char)value;
}
}
}