Example #1
0
    private void PrepareContainer()
    {
        UsefulContainer.Builder.RegisterType <NetworkController>().As <INetworkController>().SingleInstance();
        UsefulContainer.Builder.RegisterType <SceneController>().As <ISceneController>().SingleInstance();
        UsefulContainer.Builder.RegisterInstance(MessageController  = Instantiate(_MessageController, GetComponent <Transform>()).GetComponent <IMessageController>()).As <IMessageController>().SingleInstance();
        UsefulContainer.Builder.RegisterInstance(HudController      = Instantiate(_HudController, GetComponent <Transform>()).GetComponent <IHudController>()).As <IHudController>().SingleInstance();
        UsefulContainer.Builder.RegisterInstance(EntitiesController = Instantiate(_EntitiesController, GetComponent <Transform>()).GetComponent <IEntitiesController>()).As <IEntitiesController>().SingleInstance();
        UsefulContainer.Builder.RegisterType <MessagePackGameSerializer>().As <ISerializer>();
        //
        StaticCompositeResolver.Instance.Register(
            MessagePack.Resolvers.GeneratedResolver.Instance,
            MessagePack.Resolvers.StandardResolver.Instance
            );

        var option = MessagePackSerializerOptions.Standard.WithResolver(StaticCompositeResolver.Instance);

        MessagePackSerializer.DefaultOptions = option;
        //
        UsefulContainer.Builder.RegisterType <PacketFactory>().As <IPacketFactory>().SingleInstance();
        UsefulContainer.Builder.RegisterInstance(this).As <GameController>().SingleInstance();
        UsefulContainer.Builder.RegisterAssemblyTypes(new LoginFailedHandler(null).GetType().Assembly).AsClosedTypesOf(typeof(GenericPacketHandlerAsync <>)).PropertiesAutowired();

        /*CompositeResolver.Register(
         *      new IMessagePackFormatter[]
         *      {
         *          //PrimitiveObjectFormatter.Instance,
         *          NullableStringFormatter.Instance,
         *          new DynamicObjectTypeFallbackFormatter(new IFormatterResolver[] { GeneratedResolver.Instance })
         *      },
         *      new IFormatterResolver[]
         *      {
         *          //StandardResolver.Instance,
         *          GeneratedResolver.Instance,
         *      });*/
        //UsefulContainer.Builder.RegisterInstance(CompositeResolver.Instance).As<IFormatterResolver>();
    }
 public EntityMapper(IEntitiesController entitiesController, IRegionController regionController)
 {
     _eaEntitiesController    = entitiesController;
     _magentoRegionController = regionController;
 }