fastBinaryJSON/BJsonSerializer.cs

(开头部分) 18KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections;
using System.Collections.Generic;
#if SILVERLIGHT

#else
using System.Data;
#endif
using System.Globalization;
using System.IO;
using System.Text;
using System.Collections.Specialized;

namespace fastBinaryJSON
{
    internal sealed class BJSONSerializer
    {
        private MemoryStream _output = new MemoryStream();
        private MemoryStream _before = new MemoryStream();
        readonly int _MAX_DEPTH = 20;
        int _current_depth = 0;
        private Dictionary<string, int> _globalTypes = new Dictionary<string, int>();
        private Dictionary<object, int> _cirobj = new Dictionary<object, int>();
        private BJSONParameters _params;
        //private bool _circular = false;

        internal BJSONSerializer(BJSONParameters param)
        {
            _params = param;
        }

        internal byte[] ConvertToBJSON(object obj)
        {
            WriteValue(obj);
            //if (_circular)
            //{
            //    _before.WriteByte(TOKENS.NAME);
            //    byte[] b = Reflection.Instance.utf8.GetBytes("$circular");
            //    _before.WriteByte((byte)b.Length);
            //    _before.Write(b, 0, b.Length % 256);
            //    _before.WriteByte(TOKENS.COLON);
            //    _before.WriteByte(TOKENS.TRUE);
            //}
            // add $types
            if (_params.UsingGlobalTypes && _globalTypes != null && _globalTypes.Count>0)
            {
                byte[] after = _output.ToArray();
                _output = _before;
                WriteName("$types");
                WriteColon();
                WriteTypes(_globalTypes);
                WriteComma();
                _output.Write(after, 0, after.Length);

                return _output.ToArray();
            }

            return _output.ToArray();
        }

后面还有 561 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。