Example #1
0
        public DeserilaizationBenchmark()
        {
            //JSON.NET Setup
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Converters = new List <JsonConverter>
                {
                    new DateJsonSerializer()
                }
            };
            _jsonInput = File.ReadAllText(@"Serialization\MonthlyFeeEvent.json");
            _bsonInput = File.ReadAllBytes(@"Serialization\MonthlyFeeEvent.bson");

            //MsgPack.Cli setup
            var context = new SerializationContext();

            context.Serializers.Register(new DateMsgPackSerializer(context));
            context.SerializationMethod = SerializationMethod.Map;
            _msgPackserializer          = context.GetSerializer <MonthlyFeeChargedEvent>(context);
            _msgPackProxySerializer     = context.GetSerializer <MonthlyFeeChargedEventProxy>(context);
            _fullMsgPackInput           = File.ReadAllBytes(@"Serialization\MonthlyFeeEvent.msgpack");

            //MessagePack-CS set up
            CompositeResolver.RegisterAndSetAsDefault(
                CustomCompositeResolver.Instance,
                ContractlessStandardResolver.Instance
                );
            _csPayload    = File.ReadAllBytes(@"Serialization\MonthlyFeeEvent.MessagePack");
            _lz4CsPayload = File.ReadAllBytes(@"Serialization\MonthlyFeeEvent.MessagePack.lz4");
        }
Example #2
0
        static List <MindMapConfig> GetConfig()
        {
            var configFileName = Path.Combine(Environment.CurrentDirectory, "MindMapsConfig.json");

            CompositeResolver.RegisterAndSetAsDefault(new IJsonFormatter[] { new TimeSpanFormatter() }, new IJsonFormatterResolver[] { StandardResolver.Default });
            if (!File.Exists(configFileName))
            {
                var newConfig = new List <MindMapConfig>();
                newConfig.Add(new MindMapConfig());
                var enConfig = new MindMapConfig();
                enConfig.DestPath = enConfig.DestPath.Replace("Fr", "En");
                enConfig.DescriptionExpression = enConfig.DescriptionExpression.Replace("Fr", "En");
                enConfig.TitleExpression       = enConfig.TitleExpression.Replace("Fr", "En");
                enConfig.ExampleExpression     = enConfig.ExampleExpression.Replace("Fr", "En");
                enConfig.LinkExpression        = enConfig.LinkExpression.Replace("Fr", "En");
                newConfig.Add(enConfig);
                var strNewConfig = JsonSerializer.PrettyPrint(JsonSerializer.ToJsonString(newConfig));
                File.WriteAllText(configFileName, strNewConfig);
            }

            using var configStream = File.OpenRead(configFileName);
            var config = JsonSerializer.Deserialize <List <MindMapConfig> >(configStream);

            return(config);
        }
Example #3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            CompositeResolver.RegisterAndSetAsDefault(new[]
            {
                EnumResolver.UnderlyingValue,
                StandardResolver.ExcludeNullCamelCase
            });

            Persistence.Extensions.DIHelper.OnServicesSetup(app.ApplicationServices);

            //Seed initial shipservices
            var shipServiceManager = app.ApplicationServices.GetService <IShipServiceManager>();

            if (shipServiceManager.GetShipServicesCount().GetAwaiter().GetResult() == 0)
            {
                SeedHelper.Seed(shipServiceManager).GetAwaiter().GetResult();
            }

            app.UseMvc();
        }
Example #4
0
        static void Main(string[] args)
        {
            CompositeResolver.RegisterAndSetAsDefault(new[]
            {
                EnumResolver.UnderlyingValue,
                StandardResolver.ExcludeNullCamelCase
            });

            //bind eventhandlers
            IEventHandler         eventHandler         = ServiceProvider.GetService <IEventHandler>();
            IEventHandlerCallback eventHandlerCallback = ServiceProvider.GetService <IEventHandlerCallback>();

            try
            {
                eventHandler.Start(eventHandlerCallback);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occured during eventhandler startup check logs for info" + ex.Message);
                Environment.Exit(1);
            }

            Console.WriteLine("Up and running and ready to rumble!");
            while (true)
            {
                Thread.Sleep(10000);
            }
        }
Example #5
0
        public Form1()
        {
            //Set MessagePack Resolvers
            CompositeResolver.RegisterAndSetAsDefault(
                DynamicObjectResolverAllowPrivate.Instance,
                StandardResolver.Instance
                );

            InitializeComponent();

            complexAnimationData = new ComplexAnimation();
            //labelFrameCount.DataBindings.Add(complexAnimationData.GetFrameCountDataBinding()); //Not working ...
            complexAnimationData.OnFrameCountChanged(ComplexDataFramecountChanged);

            IEnumerable <Animation.AnimationType> animationTypes = Enum.GetValues(typeof(Animation.AnimationType)).Cast <Animation.AnimationType>();

            foreach (Animation.AnimationType aT in animationTypes)
            {
                comboBoxAnimationType.Items.Add(aT.ToString());
            }
            comboBoxAnimationType.SelectedItem  = null;
            comboBoxAnimationType.SelectedIndex = 1;

            UpdateFrameDataOutput(-1);
        }
Example #6
0
        public static async Task <int> Main(string[] args)
        {
            CompositeResolver.RegisterAndSetAsDefault(FSharpResolver.Instance, StandardResolver.Default);

            try
            {
                await BatchHost
                .CreateDefaultBuilder()
                .UseServiceProviderFactory <IUnityContainer>(new ServiceProviderFactory(new UnityContainer()))
                .ConfigureContainer <IUnityContainer>((hostContext, container) =>
                {
                    container.RegisterInstance <IMessageBroker>(Reactive.Bindings.Notifiers.MessageBroker.Default);
                    container.RegisterInstance <IUnityContainer>(container);

                    container.RegisterType <ICommandBus, CommandBus>();
                    container.RegisterType <I発送本DTOQuery, 発送本DTOQuery>();
                    container.RegisterType <I本を発送するCommand, 本を発送するCommand>();
                    container.RegisterType <I本を発送するCommandHandler, 本を発送するCommandHandler>();
                })
                .RunBatchEngineAsync <Scenario>(args);

                return(Environment.ExitCode);
            }
            catch (Exception ex) when((ex is ArgumentException) || (ex is ArgumentNullException))
            {
                Console.WriteLine(ex.Message);
                return(1);
            }
            catch (Exception)
            {
                return(9);
            }
        }
Example #7
0
        static void CheckUnsfeResolver()
        {
            UnsafeDirectBlitResolver.Register <Foo>();
            CompositeResolver.RegisterAndSetAsDefault(
                UnsafeDirectBlitResolver.Instance,

                BuiltinResolver.Instance

                );

            var f = new Foo {
                A = 10, B = 9999, C = 9999999
            };
            var doudarou = MessagePackSerializer.Serialize(f, UnsafeDirectBlitResolver.Instance);
            var two      = MessagePackSerializer.Deserialize <Foo>(doudarou);


            var f2 = new[] {
                new Foo {
                    A = 10, B = 9999, C = 9999999
                },
                new Foo {
                    A = 101, B = 43, C = 234
                },
                new Foo {
                    A = 20, B = 5666, C = 1111
                },
            };
            var doudarou2 = MessagePackSerializer.Serialize(f2, UnsafeDirectBlitResolver.Instance);
            var two2      = MessagePackSerializer.Deserialize <Foo[]>(doudarou2);


            Console.WriteLine(string.Join(", ", doudarou2));
        }
Example #8
0
 static UserData()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         ImmutableCollectionResolver.Instance,
         StandardResolverAllowPrivate.Instance
         );
 }
Example #9
0
        internal void OutputJSON(object jObj, ListFlags toolFlags)
        {
            try {
                CompositeResolver.RegisterAndSetAsDefault(new IJsonFormatter[] {
                    new ResourceGUIDFormatter()
                }, new[] {
                    StandardResolver.Default
                });
            } catch {
                // rip, already registered and set as default???
            }

            byte[] json = Utf8Json.JsonSerializer.NonGeneric.Serialize(jObj.GetType(), jObj);
            if (!string.IsNullOrWhiteSpace(toolFlags.Output))
            {
                byte[] pretty = Utf8Json.JsonSerializer.PrettyPrintByteArray(json);

                Log("Writing to {0}", toolFlags.Output);

                CreateDirectoryFromFile(toolFlags.Output);

                var fileName = !toolFlags.Output.EndsWith(".json") ? $"{toolFlags.Output}.json" : toolFlags.Output;

                using (Stream file = File.OpenWrite(fileName)) {
                    file.SetLength(0);
                    file.Write(pretty, 0, pretty.Length);
                }
            }
            else
            {
                Console.Error.WriteLine(Utf8Json.JsonSerializer.PrettyPrint(json));
            }
        }
Example #10
0
        private static IServiceProvider BuildServiceProvider()
        {
            // Register the MessagePack resolvers
            // TODO: should this be here?
            CompositeResolver.RegisterAndSetAsDefault(
                CoreLibrary.Generated.Resolvers.CoreLibraryGeneratedResolver.Instance,
                DRXLibrary.Generated.Resolvers.DRXLibraryGeneratedResolver.Instance,
                BuiltinResolver.Instance,
                AttributeFormatterResolver.Instance,
                PrimitiveObjectResolver.Instance
                );

            var collection = new ServiceCollection();

            collection.AddLogging();
            collection.AddSingleton(typeof(StoreService));
            collection.AddSingleton(typeof(UserService));

            _serviceProvider = collection.BuildServiceProvider();
            var factory = _serviceProvider.GetService <ILoggerFactory>();

            factory.AddFile($"{ApplicationData.Current.LocalFolder.Path}\\logs\\app.log");
            App.RegisterCrashLogger(factory.CreateLogger("ExceptionHandler"));

            return(_serviceProvider);
        }
Example #11
0
 static MsgPackSerializer()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         ActorPathResolver.Instance,
         OldSpecResolver.Instance, // Redis compatible MsgPack spec
         ContractlessStandardResolver.Instance);
 }
        static void Main(string[] args)
        {
            CompositeResolver.RegisterAndSetAsDefault(new[]
            {
                EnumResolver.UnderlyingValue,
                StandardResolver.ExcludeNullCamelCase
            });

            // Get the message handler
            IMessageHandler         messageHandler         = ServiceProvider.GetService <IMessageHandler>();
            IMessageHandlerCallback messageHandlerCallback = ServiceProvider.GetService <IMessageHandlerCallback>();

            try
            {
                Console.WriteLine("Starting handler");
                messageHandler.Start(messageHandlerCallback);
                Console.WriteLine("Handler started");
            }
            catch (Exception ex)
            {
                // Error during staring
                Console.Error.WriteLine($"Error during starting message handler, message: {ex.Message}");
                Environment.Exit(1);
            }

            Console.WriteLine("Security service started.");
            while (true)
            {
                Thread.Sleep(10000);
            }
        }
    private static void BuildMasterData()
    {
        try {
            CompositeResolver.RegisterAndSetAsDefault(new [] {
                MasterMemoryResolver.Instance,
                GeneratedResolver.Instance,
                StandardResolver.Instance
            });
        } catch { }

        var builder = new DatabaseBuilder();

        builder = BuildParson(builder);
        builder = BuildSkill(builder);
        builder = BuildSkillParameter(builder);

        byte[] data = builder.Build();

        var resourcesDir = $"{Application.dataPath}/Resources";

        Directory.CreateDirectory(resourcesDir);
        var filename = "/master-data.bytes";

        using (var fs = new FileStream(resourcesDir + filename, FileMode.Create)) {
            fs.Write(data, 0, data.Length);
        }

        Debug.Log($"Write byte[] to: {resourcesDir + filename}");

        AssetDatabase.Refresh();
    }
 public static void SetupMessagePackResolver()
 {
     CompositeResolver.RegisterAndSetAsDefault(new [] {
         MasterMemoryResolver.Instance, // set MasterMemory generated resolver
         GeneratedResolver.Instance,    // set MessagePack generated resolver
         StandardResolver.Instance      // set default MessagePack resolver
     });
 }
 static MessagePackSerializer()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         new[]
     {
         NativeDateTimeResolver.Instance,
         ContractlessStandardResolver.Instance
     });
 }
 static MsgPackSerializer()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         SerializableResolver.Instance,
         //ExceptionFallbackResolver.Instance,
         AkkaResolver.Instance,
         ImmutableCollectionResolver.Instance,
         TypelessContractlessStandardResolver.Instance);
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:EasyCaching.Serialization.MessagePack.DefaultMessagePackSerializer"/> class.
 /// </summary>
 public DefaultMessagePackSerializer()
 {
     MessagePackSerializer.SetDefaultResolver(CompositeResolver.Instance);
     CompositeResolver.RegisterAndSetAsDefault(
         // Resolve DateTime first
         NativeDateTimeResolver.Instance
         , ContractlessStandardResolver.Instance
         );
 }
Example #18
0
 public void Setup()
 {
     CompositeResolver.RegisterAndSetAsDefault(new IJsonFormatter[] { new GlyphDataFormatter() }, new[] { StandardResolver.Default });
     _glyphSource = new GlyphData()
     {
         FormDefinitionKey = Guid.NewGuid(), PageNumber = 1
     };
     _jsonSource = (new JsonGlyphSerializer()).Serialize(_glyphSource);
 }
Example #19
0
 void Start()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         GeneratedResolver.Instance,
         MessagePack.Unity.UnityResolver.Instance,
         BuiltinResolver.Instance,
         AttributeFormatterResolver.Instance,
         PrimitiveObjectResolver.Instance
         );
 }
Example #20
0
 static void RegisterResolvers()
 {
     CompositeResolver.RegisterAndSetAsDefault
     (
         MagicOnion.Resolvers.MagicOnionResolver.Instance,
         MessagePack.Resolvers.GeneratedResolver.Instance,
         BuiltinResolver.Instance,
         PrimitiveObjectResolver.Instance
     );
 }
Example #21
0
 public ResolverFixture()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         BuiltinResolver.Instance,
         NodatimeResolver.Instance,
         AttributeFormatterResolver.Instance,
         DynamicEnumAsStringResolver.Instance,
         ContractlessStandardResolver.Instance
         );
 }
Example #22
0
        static MsgPackSerializer()
        {
            CompositeResolver.RegisterAndSetAsDefault(
#if SERIALIZATION
                SerializableResolver.Instance,
#endif
                AkkaResolver.Instance,
                ImmutableCollectionResolver.Instance,
                TypelessContractlessStandardResolver.Instance);
        }
Example #23
0
        public static void Initialize()
        {
            CompositeResolver.RegisterAndSetAsDefault(new IJsonFormatter[] {
                new DateTimeFormatter("yyyy-MM-ddTHH:mm:ssZ"),
                new NullableDateTimeFormatter("yyyy-MM-ddTHH:mm:ssZ")
            }, new[] {
                EnumResolver.UnderlyingValue,

                StandardResolver.AllowPrivateExcludeNullSnakeCase
            });
        }
Example #24
0
        public static void Main(string[] args)
        {
            CompositeResolver.RegisterAndSetAsDefault(new[] {
                // resolver custom types first
                AttributeFormatterResolver.Instance,
                DynamicGenericResolver.Instance,
                StandardResolver.CamelCase
            });
            JsonSerializer.SetDefaultResolver(CompositeResolver.Instance);

            CreateHostBuilder(args).Build().Run();
        }
        public MessagePackSerializerTest2()
        {
            CompositeResolver.RegisterAndSetAsDefault(
                // This can solve DateTime time zone problem
                NativeDateTimeResolver.Instance,
                ContractlessStandardResolver.Instance
                );

            _serializer = new DefaultMessagePackSerializer("msgpack", new EasyCachingMsgPackSerializerOptions {
                EnableCustomResolver = true
            });
        }
Example #26
0
 static void RegisterResolvers()
 {
     CompositeResolver.RegisterAndSetAsDefault
     (
         MagicOnion.Resolvers.MagicOnionResolver.Instance,
         MessagePack.Resolvers.GeneratedResolver.Instance,
         // MessagePack.Resolvers.Client.GeneratedResolver.Instance,
         RM.Hotel.Shared.Resolvers.CustomResolver.Instance,
         BuiltinResolver.Instance,
         PrimitiveObjectResolver.Instance
     );
 }
Example #27
0
        private static void SetupMessagePackResolvers()
        {
            // CompositeResolver is singleton helper for use custom resolver.
            // Of course you can also make custom resolver.
            CompositeResolver.RegisterAndSetAsDefault(
                // use generated resolver first, and combine many other generated/custom resolvers
                GeneratedResolver.Instance,

                // finally, use builtin/primitive resolver(don't use StandardResolver, it includes dynamic generation)
                BuiltinResolver.Instance,
                AttributeFormatterResolver.Instance,
                PrimitiveObjectResolver.Instance);
        }
Example #28
0
            public StackExchangeRedisExtensionsMessagePackSerializer()
            {
                ///Does not work as the times get converted to UTC
                //MessagePackSerializer.SetDefaultResolver(MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.Instance);

                //Works!!!
                //CompositeResolver.RegisterAndSetAsDefault(
                //    new[] { new DurableDateTimeFormatter() },
                //    new[] { MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.Instance });

                ///Works!!
                CompositeResolver.RegisterAndSetAsDefault(new[] { NativeDateTimeResolver.Instance, ContractlessStandardResolverAllowPrivate.Instance });
            }
Example #29
0
 public NOC()
 {
     CompositeResolver.RegisterAndSetAsDefault(
         BuiltinResolver.Instance,
         PrimitiveObjectResolver.Instance,
         AttributeFormatterResolver.Instance,
         UnityResolver.Instance,
         DynamicEnumAsStringResolver.Instance,
         DynamicGenericResolver.Instance,
         DynamicUnionResolver.Instance,
         DynamicObjectResolver.Instance,
         DynamicContractlessObjectResolver.Instance
         );
 }
Example #30
0
        static void Main(string[] args)
        {
            //Random rnd = new Random();
            //int taskID = rnd.Next(3541, 91311);
            var persons = GetPersonList();

            CompositeResolver.RegisterAndSetAsDefault(
                ContractlessStandardResolver.Instance,
                NativeDateTimeResolver.Instance,
                StandardResolver.Instance
                );

            TryMsgPack(111, persons);
        }