Exemple #1
0
        public SerializationLargeGraph()
        {
            var initial = new TopLevel(Guid.NewGuid(),
                                       ImmutableSortedDictionary <string, FirstLevelChild> .Empty.WithComparers(StringComparer.OrdinalIgnoreCase),
                                       0, "Tag", "Description");

            var current = initial;

            for (int i = 0; i < 1000; ++i)
            {
                if (i % 10 == 0)
                {
                    _t1.Add(current);
                }

                if (i % 10 == 0)
                {
                    current = AddFirstLevelChild(current);
                }

                current = AddSecondLevelChild(current);
            }

            var config = new SerializerConfig {
                DefaultTargets = TargetMember.AllFields, PreserveReferences = true
            };

            config.Advanced.ReadonlyFieldHandling = ReadonlyFieldHandling.ForcedOverwrite;
            config.OnConfigNewType = tc => tc.TypeConstruction = TypeConstruction.ByUninitialized();
            config.UseImmutableFormatters();
            ceras = new CerasSerializer(config);

            //_hyperion.Serialize(_t1, _m2);

            _msgPackOptions = MessagePackSerializerOptions.Standard.WithResolver(
                CompositeResolver.Create(
                    ImmutableCollectionResolver.Instance,
                    DynamicObjectResolver.Instance,
                    StandardResolver.Instance
                    )
                );

            //_netSerializer.Serialize(_m5, _t1);
        }