public DictionariesSerialization()
        {
            _serializer = Binary.Create(new Settings {
                SerializationMode = Mode.Graph
            });
            _dict          = new Dictionary <int, int>();
            _immDict       = ImmutableDictionary <int, int> .Empty;
            _immSortedDict = ImmutableSortedDictionary <int, int> .Empty;
            _sasaTrie      = Trie <int, int> .Empty;
            _hashMap       = HashMap <int, int> .Empty;

            for (int i = 0; i < 10000; ++i)
            {
                _dict.Add(i, i);
                _immDict       = _immDict.SetItem(i, i);
                _immSortedDict = _immSortedDict.SetItem(i, i);
                _sasaTrie      = _sasaTrie.Add(i, i);
                _hashMap       = _hashMap.SetItem(i, i);
            }

            _dStream       = new MemoryStream();
            _idStream      = new MemoryStream();
            _isdStream     = new MemoryStream();
            _sasaStream    = new MemoryStream();
            _hashMapStream = new MemoryStream();

            _serializer.Write(_dict, _dStream);
            _serializer.Write(_immDict, _idStream);
            _serializer.Write(_immSortedDict, _isdStream);
            _serializer.Write(_sasaTrie, _sasaStream);
            _serializer.Write(_hashMap, _hashMapStream);
        }
Example #2
0
        protected void SerializeWithoutFlattenClassHierarchy <T>(T obj)
        {
            m4.Position = 0;
            binaryWithoutFlatten.Write(obj, m4);

            //ceras.Serialize(obj, ref b);
        }
Example #3
0
        protected void SerializeWithVersionIds <T>(T obj)
        {
            m3.Position = 0;
            binaryWithVersionIds.Write(obj, m3);

            //ceras.Serialize(obj, ref b);
        }
Example #4
0
        protected void SerializeGraph <T>(T obj)
        {
            m2.Position = 0;
            binaryGraph.Write(obj, m2);

            //ceras.Serialize(obj, ref b);
        }
Example #5
0
        protected void Serialize <T>(T obj)
        {
            m1.Position = 0;
            binary.Write(obj, m1);

            //ceras.Serialize(obj, ref b);
        }
        public SerializationMutablePoco()
        {
            for (int i = 0; i < 1000; ++i)
            {
                _t1.Add(new Poco {
                    StringProp = "hello", IntProp = 123, GuidProp = Guid.NewGuid(), DateProp = DateTime.Now
                });
            }

            //_hyperion.Serialize(_t1, _m2);
            ProtoBuf.Serializer.Serialize(_m3, _t1);
            MessagePackSerializer.Serialize(_m4, _t1);
            _netSerializer.Serialize(_m5, _t1);
            ceras.Serialize(_t1, ref b);
            _binary.Write(_t1, _m1);
        }
Example #7
0
 /// <summary>
 /// バイナリデータ取得
 /// </summary>
 public static byte[] GetBinary(this IBinary bin)
 {
     using (var stream = new MemoryStream())
         using (var writer = new BinaryWriter(stream))
         {
             bin.Write(writer);
             return(stream.GetBuffer());
         }
 }
Example #8
0
        public SerializationImmutablePoco()
        {
            var config = new SerializerConfig {
                DefaultTargets = TargetMember.AllFields, PreserveReferences = false
            };

            config.Advanced.ReadonlyFieldHandling       = ReadonlyFieldHandling.ForcedOverwrite;
            config.Advanced.SkipCompilerGeneratedFields = false;
            config.ConfigType <ImmutablePoco>().ConstructByUninitialized();
            ceras = new CerasSerializer(config);

            for (int i = 0; i < 1000; ++i)
            {
                _t1.Add(new ImmutablePoco("hello", 123, Guid.NewGuid(), DateTime.Now));
            }

            //_hyperion.Serialize(_t1, _m2);
            ProtoBuf.Serializer.Serialize(_m3, _t1);
            MessagePackSerializer.Serialize(_m4, _t1);
            _netSerializer.Serialize(_m5, _t1);
            _binary.Write(_t1, _m1);
        }
 public void SetupApex()
 {
     _binary.Write(_t1, _m1);
 }
 public void SetupApex()
 {
     _binaryTree.Write(_t1, _m5);
 }
 public void Apex1()
 {
     _apexStream.Seek(0, SeekOrigin.Begin);
     _apex.Write(Model, _apexStream);
 }
 public void SerializeDictionary()
 {
     _dStream.Seek(0, SeekOrigin.Begin);
     _serializer.Write(_dict, _dStream);
 }
Example #13
0
 public void S_Apex()
 {
     _m1.Seek(0, SeekOrigin.Begin);
     _binary.Write(_t1, _m1);
 }
 public void Apex()
 {
     _memoryStream.Seek(0, SeekOrigin.Begin);
     _binaryTree.Write(_t1, _memoryStream);
 }