Пример #1
0
        ProxyArray DecodeArray()
        {
            var proxy = new ProxyArray();

            // Ditch opening bracket.
            json.Read();

            // [
            var parsing = true;

            while (parsing)
            {
                var nextToken = NextToken;

                // ReSharper disable once SwitchStatementMissingSomeCases
                switch (nextToken)
                {
                case Token.None:
                    return(null);

                case Token.Comma:
                    continue;

                case Token.CloseBracket:
                    parsing = false;
                    break;

                default:
                    proxy.Add(DecodeByToken(nextToken));
                    break;
                }
            }

            return(proxy);
        }
Пример #2
0
        // ReSharper disable once UnusedMember.Local
        static void DecodeMultiRankArray <T>(ProxyArray arrayData, Array array, int arrayRank, int[] indices)
        {
            var count = arrayData.Count;

            for (var i = 0; i < count; i++)
            {
                indices[arrayRank - 1] = i;
                if (arrayRank < array.Rank)
                {
                    DecodeMultiRankArray <T>(arrayData[i] as ProxyArray, array, arrayRank + 1, indices);
                }
                else
                {
                    array.SetValue(DecodeType <T>(arrayData[i]), indices);
                }
            }
        }