Esempio n. 1
0
    // Token: 0x060006E8 RID: 1768 RVA: 0x0002CB48 File Offset: 0x0002AD48
    public static void smethod_2(TextWriter textWriter_0, string string_0, char char_0, bool bool_3, object object_0, StringEscapeHandling stringEscapeHandling_0, IArrayPool <char> iarrayPool_0, ref char[] char_1)
    {
        if (bool_3)
        {
            textWriter_0.Write(char_0);
        }
        if (!string.IsNullOrEmpty(string_0))
        {
            int num = Class70.smethod_4(string_0, object_0, stringEscapeHandling_0);
            if (num == -1)
            {
                textWriter_0.Write(string_0);
            }
            else
            {
                if (num != 0)
                {
                    if (char_1 == null || char_1.Length < num)
                    {
                        char_1 = Class69.smethod_2(iarrayPool_0, num, char_1);
                    }
                    string_0.CopyTo(0, char_1, 0, num);
                    textWriter_0.Write(char_1, 0, num);
                }
                int num2;
                for (int i = num; i < string_0.Length; i++)
                {
                    char c = string_0[i];
                    if ((int)c >= object_0.Length || object_0[(int)c])
                    {
                        string text;
                        if (c <= '\\')
                        {
                            switch (c)
                            {
                            case '\b':
                                text = "\\b";
                                break;

                            case '\t':
                                text = "\\t";
                                break;

                            case '\n':
                                text = "\\n";
                                break;

                            case '\v':
                                goto IL_10D;

                            case '\f':
                                text = "\\f";
                                break;

                            case '\r':
                                text = "\\r";
                                break;

                            default:
                                if (c != '\\')
                                {
                                    goto IL_10D;
                                }
                                text = "\\\\";
                                break;
                            }
                        }
                        else if (c != '\u0085')
                        {
                            if (c != '\u2028')
                            {
                                if (c != '\u2029')
                                {
                                    goto IL_10D;
                                }
                                text = "\\u2029";
                            }
                            else
                            {
                                text = "\\u2028";
                            }
                        }
                        else
                        {
                            text = "\\u0085";
                        }
IL_185:
                        if (text == null)
                        {
                            goto IL_229;
                        }
                        bool flag = string.Equals(text, "!", StringComparison.Ordinal);
                        if (i > num)
                        {
                            num2 = i - num + (flag ? 6 : 0);
                            int num3 = flag ? 6 : 0;
                            if (char_1 == null || char_1.Length < num2)
                            {
                                char[] array = Class69.smethod_0(iarrayPool_0, num2);
                                if (flag)
                                {
                                    Array.Copy(char_1, array, 6);
                                }
                                Class69.smethod_1(iarrayPool_0, char_1);
                                char_1 = array;
                            }
                            string_0.CopyTo(num, char_1, num3, num2 - num3);
                            textWriter_0.Write(char_1, num3, num2 - num3);
                        }
                        num = i + 1;
                        if (!flag)
                        {
                            textWriter_0.Write(text);
                            goto IL_229;
                        }
                        textWriter_0.Write(char_1, 0, 6);
                        goto IL_229;
IL_10D:
                        if ((int)c >= object_0.Length)
                        {
                            if (stringEscapeHandling_0 != StringEscapeHandling.EscapeNonAscii)
                            {
                                text = null;
                                goto IL_185;
                            }
                        }
                        if (c == '\'' && stringEscapeHandling_0 != StringEscapeHandling.EscapeHtml)
                        {
                            text = "\\'";
                            goto IL_185;
                        }
                        if (c == '"' && stringEscapeHandling_0 != StringEscapeHandling.EscapeHtml)
                        {
                            text = "\\\"";
                            goto IL_185;
                        }
                        if (char_1 == null || char_1.Length < 6)
                        {
                            char_1 = Class69.smethod_2(iarrayPool_0, 6, char_1);
                        }
                        Class97.smethod_7(c, char_1);
                        text = "!";
                        goto IL_185;
                    }
                    IL_229 :;
                }
                num2 = string_0.Length - num;
                if (num2 > 0)
                {
                    if (char_1 == null || char_1.Length < num2)
                    {
                        char_1 = Class69.smethod_2(iarrayPool_0, num2, char_1);
                    }
                    string_0.CopyTo(num, char_1, 0, num2);
                    textWriter_0.Write(char_1, 0, num2);
                }
            }
        }
        if (bool_3)
        {
            textWriter_0.Write(char_0);
        }
    }
Esempio n. 2
0
    // Token: 0x060006F0 RID: 1776 RVA: 0x0002D080 File Offset: 0x0002B280
    private static async Task smethod_10(TextWriter textWriter_0, string string_0, int int_0, bool[] bool_3, StringEscapeHandling stringEscapeHandling_0, JsonTextWriter jsonTextWriter_0, char[] char_0, CancellationToken cancellationToken_0)
    {
        if (char_0 == null || char_0.Length < int_0)
        {
            char_0 = jsonTextWriter_0.method_95(int_0, 6);
        }
        if (int_0 != 0)
        {
            string_0.CopyTo(0, char_0, 0, int_0);
            await textWriter_0.smethod_6(char_0, 0, int_0, cancellationToken_0).ConfigureAwait(false);
        }
        bool   isEscapedUnicodeText = false;
        string escapedValue         = null;
        int    num;

        ConfiguredTaskAwaitable.ConfiguredTaskAwaiter configuredTaskAwaiter2;
        for (int i = int_0; i < string_0.Length; i++)
        {
            char c = string_0[i];
            if ((int)c >= bool_3.Length || bool_3[(int)c])
            {
                if (c <= '\\')
                {
                    switch (c)
                    {
                    case '\b':
                        escapedValue = "\\b";
                        goto IL_308;

                    case '\t':
                        escapedValue = "\\t";
                        goto IL_308;

                    case '\n':
                        escapedValue = "\\n";
                        goto IL_308;

                    case '\v':
                        break;

                    case '\f':
                        escapedValue = "\\f";
                        goto IL_308;

                    case '\r':
                        escapedValue = "\\r";
                        goto IL_308;

                    default:
                        if (c == '\\')
                        {
                            escapedValue = "\\\\";
                            goto IL_308;
                        }
                        break;
                    }
                }
                else
                {
                    if (c == '\u0085')
                    {
                        escapedValue = "\\u0085";
                        goto IL_308;
                    }
                    if (c == '\u2028')
                    {
                        escapedValue = "\\u2028";
                        goto IL_308;
                    }
                    if (c == '\u2029')
                    {
                        escapedValue = "\\u2029";
                        goto IL_308;
                    }
                }
                if ((int)c >= bool_3.Length && stringEscapeHandling_0 != StringEscapeHandling.EscapeNonAscii)
                {
                    goto IL_410;
                }
                if (c == '\'' && stringEscapeHandling_0 != StringEscapeHandling.EscapeHtml)
                {
                    escapedValue = "\\'";
                }
                else if (c == '"' && stringEscapeHandling_0 != StringEscapeHandling.EscapeHtml)
                {
                    escapedValue = "\\\"";
                }
                else
                {
                    if (char_0.Length < 6)
                    {
                        char_0 = jsonTextWriter_0.method_95(6, 0);
                    }
                    Class97.smethod_7(c, char_0);
                    isEscapedUnicodeText = true;
                }
IL_308:
                if (i > int_0)
                {
                    num = i - int_0 + (isEscapedUnicodeText ? 6 : 0);
                    int num2 = isEscapedUnicodeText ? 6 : 0;
                    if (char_0.Length < num)
                    {
                        char_0 = jsonTextWriter_0.method_95(num, 6);
                    }
                    string_0.CopyTo(int_0, char_0, num2, num - num2);
                    ConfiguredTaskAwaitable.ConfiguredTaskAwaiter configuredTaskAwaiter = textWriter_0.smethod_6(char_0, num2, num - num2, cancellationToken_0).ConfigureAwait(false).GetAwaiter();
                    if (!configuredTaskAwaiter.IsCompleted)
                    {
                        await configuredTaskAwaiter;
                        configuredTaskAwaiter  = configuredTaskAwaiter2;
                        configuredTaskAwaiter2 = default(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter);
                    }
                    configuredTaskAwaiter.GetResult();
                }
                int_0 = i + 1;
                if (!isEscapedUnicodeText)
                {
                    ConfiguredTaskAwaitable.ConfiguredTaskAwaiter configuredTaskAwaiter = textWriter_0.smethod_5(escapedValue, cancellationToken_0).ConfigureAwait(false).GetAwaiter();
                    if (!configuredTaskAwaiter.IsCompleted)
                    {
                        await configuredTaskAwaiter;
                        configuredTaskAwaiter  = configuredTaskAwaiter2;
                        configuredTaskAwaiter2 = default(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter);
                    }
                    configuredTaskAwaiter.GetResult();
                }
                else
                {
                    ConfiguredTaskAwaitable.ConfiguredTaskAwaiter configuredTaskAwaiter = textWriter_0.smethod_6(char_0, 0, 6, cancellationToken_0).ConfigureAwait(false).GetAwaiter();
                    if (!configuredTaskAwaiter.IsCompleted)
                    {
                        await configuredTaskAwaiter;
                        configuredTaskAwaiter  = configuredTaskAwaiter2;
                        configuredTaskAwaiter2 = default(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter);
                    }
                    configuredTaskAwaiter.GetResult();
                    isEscapedUnicodeText = false;
                }
            }
            IL_410 :;
        }
        num = string_0.Length - int_0;
        if (num != 0)
        {
            if (char_0.Length < num)
            {
                char_0 = jsonTextWriter_0.method_95(num, 0);
            }
            string_0.CopyTo(int_0, char_0, 0, num);
            ConfiguredTaskAwaitable.ConfiguredTaskAwaiter configuredTaskAwaiter = textWriter_0.smethod_6(char_0, 0, num, cancellationToken_0).ConfigureAwait(false).GetAwaiter();
            if (!configuredTaskAwaiter.IsCompleted)
            {
                await configuredTaskAwaiter;
                configuredTaskAwaiter  = configuredTaskAwaiter2;
                configuredTaskAwaiter2 = default(ConfiguredTaskAwaitable.ConfiguredTaskAwaiter);
            }
            configuredTaskAwaiter.GetResult();
        }
    }