Ejemplo n.º 1
0
        static void Main()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if (!DEBUG)
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += ApplicationOnThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
#endif

            AutoMapperConfig.Execute();
            MetadataTypesRegister.InstallForThisAssembly();
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            using (var kernel = new StandardKernel())
            {
                //Configurar bindings
                DIConfig.Configure(kernel);

                //Set global container.
                Ioc.Container = new NinjectIocContainer(kernel);

                //Config log4net
                log4net.Config.DOMConfigurator.Configure();

                MessageBoxDisplayService = Ioc.Container.Get<IMessageBoxDisplayService>();

                //Create a custom principal with an anonymous identity at startup
                var laPazPrincipal = new LaPazPrincipal();
                AppDomain.CurrentDomain.SetThreadPrincipal(laPazPrincipal);

#if(MOCK_SECURITY)
                MockUser();
#else
                using (var login = kernel.Get<FrmLogin>())
                {
                    var result = login.ShowDialog();

                    if (result == DialogResult.Cancel)
                    {
                        Application.Exit();
                        return;
                    } 
                }
#endif

                RunAfterLoginTasks();

                var mainForm = kernel.Get<FrmPrincipal>();

                Application.Run(mainForm);
            }
        }
Ejemplo n.º 2
0
 public bool IsInRole(string role)
 {
     return(LaPazPrincipal.IsInRole(role));
 }