public void SerializeSimpleObject(XsdPatternReader reader)
        {
            var stopwatch = Stopwatch.StartNew();

            var pattern = reader.Read(File.ReadAllBytes("Resources/M198_Seaside beauty.xsd"));

            output.WriteLine($"Pattern: {stopwatch.ElapsedMilliseconds} ms");

            var pattern1 = new Pattern();

            pattern1.Stitches.Add(pattern.Stitches.Select(stitch => new Stitch
            {
                X    = stitch.X,
                Y    = stitch.Y,
                Type = (StitchType)(int)stitch.Type,
                ConfigurationIndex = stitch.ConfigurationIndex
            }));

            stopwatch.Restart();

            var patternBytes = pattern1.ToByteArray();

            output.WriteLine($"Proto: {stopwatch.ElapsedMilliseconds} ms");

            File.WriteAllBytes("proto.pattern", patternBytes);

            stopwatch.Restart();

            var json = JsonConvert.SerializeObject(pattern.Stitches);

            output.WriteLine($"JSON: {stopwatch.ElapsedMilliseconds} ms");

            File.WriteAllBytes("json.pattern", Encoding.UTF8.GetBytes(json));
        }
Exemplo n.º 2
0
        private void ApplyEvent(Event @event)
        {
            switch (@event.Data)
            {
            case PatternCreated e:
                pattern = e.Pattern;
                behavior.Become(Created);
                break;

            case PatternDeleted _:
                behavior.Become(Deleted);
                break;
            }
        }