Ejemplo n.º 1
0
        protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
        {
            //var config = container.Resolve<IConfigSettings>();

            container.AttachNancyBundle <BundleConfig>(cfg =>
            {
                cfg.AddContentGroup(new CssBundles());
                cfg.AddContentGroup(new VendorJsBundles());
                cfg.AddContentGroup(new AppJsBundles());
                cfg.AddContentGroup(new MasterJsBundle());
            });

            container.Register <IConfiguration, Configuration>();
            container.Register <IUnitOfWorkFactory, UnitOfWorkFactory>();
            container.Register <ICryptoProvider, CryptoProvider>();
            container.Register <IAccountController, AccountController>();
            container.Register <ISystemController, SystemController>();
            container.Register <IBlockController, BlockController>();
            container.Register <IOperationController, OperationController>();
            container.Register <ISerializationController, SerializationController>();

            CustomStatusCode.AddCode(404);

            pipelines.OnError += (ctx, ex) =>
            {
                return(null);
            };

            var config = container.Resolve <IConfiguration>();

            if (config.BrokerType.Equals("Fake", System.StringComparison.InvariantCultureIgnoreCase))
            {
                var broker = Broker.GetBroker();
                broker.RegisterHandler <GetScreenSizeRequest>((request) =>
                {
                    var height   = 480;
                    var width    = 640;
                    var responce = new GetScreenSizeResponce
                    {
                        Height  = height * 2,
                        Width   = width * 2,
                        Screens = new ScreenSize[]
                        {
                            new ScreenSize
                            {
                                Height = height,
                                Width  = width,
                                Top    = 0,
                                Left   = 0
                            },
                            new ScreenSize
                            {
                                Height = height,
                                Width  = width,
                                Top    = 0,
                                Left   = width
                            },
                            new ScreenSize
                            {
                                Height = height,
                                Width  = width,
                                Top    = height,
                                Left   = 0
                            },
                            new ScreenSize
                            {
                                Height = height,
                                Width  = width,
                                Top    = height,
                                Left   = width
                            }
                        }
                    };
                    return(responce);
                });
                broker.RegisterHandler <GetFontsRequest>(request =>
                {
                    return(new GetFontsResponce
                    {
                        Fonts = new string[]
                        {
                            "Arial",
                            "Calibri",
                            "Comic Sans MS",
                            "Consolas",
                            "Courier New",
                            "Tahoma",
                            "Times New Roman"
                        }
                    });
                });
                broker.RegisterHandler <StartShowRequest>(reqest =>
                {
                    return(null);
                });
                broker.RegisterHandler <GetVersionRequest>(request =>
                {
                    return(new GetVersionResponce
                    {
                        Major = 12,
                        Minor = 34,
                        Build = 56
                    });
                });
            }
        }