Esempio n. 1
0
        /// <summary>
        /// Main entry of the program.
        /// </summary>
        public static void Main()
        {
            MongoObjectIdGenerator.Register();
            MongoObjectIdSerializer.Register();

            BsonClassMap.RegisterConventions(new ConventionProfile().SetSerializationOptionsConvention(new LocalDateTimeSerializationConvention()), c => true);

            IKernel kernel = new StandardKernel();

            NinjectBindings.RegisterServices(kernel);
            ServiceLocator.Resolver = kernel.GetService;

            kernel.Bind <EmailScheduler>().ToSelf();
            kernel.Bind <IBus>().To <NullBus>();
            //kernel.Load(Assembly.GetExecutingAssembly());

            var sheduller = kernel.Get <EmailScheduler>();

#if DEBUG
            sheduller.OnStart(null);
            Console.ReadKey();
#else
            try
            {
                System.ServiceProcess.ServiceBase.Run(sheduller);
            }
            catch (Exception e)
            {
                Log.Information(String.Format("Starting service failed: {0}.", e));
            }
#endif
        }
Esempio n. 2
0
        protected void Application_Start()
        {
            // MiniProfilerEF6.Initialize();

            Logger = Log4NetLogger.Configure();
            Logger.Information("App is starting");

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);

            DefaultModelBinder.ResourceClassKey = "ErrorMessages";

            ModelMetadataProviders.Current = new CustomModelMetadataProvider();

            MongoObjectIdGenerator.Register();
            MongoObjectIdSerializer.Register();
            BsonClassMap.RegisterConventions(new ConventionProfile().SetSerializationOptionsConvention(new LocalDateTimeSerializationConvention()), c => true);

            var kernel = new Ninject.Web.Common.Bootstrapper().Kernel;

            ServiceLocator.Resolver = kernel.GetService;

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new LocalizedRazorViewEngine());
            ViewEngines.Engines.Add(new LocalizedWebFormViewEngine());

            //GlobalFilters.Filters.Add(new StackExchange.Profiling.Data..Profiling.MVCHelpers.ProfilingActionFilter());

            var chatService = ServiceLocator.Resolve <ChatService>();

            chatService.ClearClients();
        }