コード例 #1
0
        public ActionResult Settings()
        {
            AllSettings a = new AllSettings();

            a.writaSettings  = _blogsettings.LoadSettings();
            a.globalSettings = _globalsettings.LoadSettings();
            return(View("~/Views/Admin/Settings.cshtml", "~/Views/Admin/_Adminlayout.cshtml", a));
        }
コード例 #2
0
        public static void Inject()
        {
            var configbuilder = new ContainerBuilder();

            configbuilder.RegisterType <FileSettingsLoader>().As <ISettingsLoader>();
            var             configcontainer = configbuilder.Build();
            ISettingsLoader i = configcontainer.Resolve <ISettingsLoader>();

            GlobalSettings = i.LoadSettings();

            builder.RegisterInstance(i).As <ISettingsLoader>();

            if (GlobalSettings.BlogDb == DbType.MONGODB)
            {
                builder.RegisterInstance(new MongoDbDataHelper(GlobalSettings)).As <IDataHelper, IBlogSettingsLoader>();
            }
            else if (GlobalSettings.BlogDb == DbType.EF)
            {
                builder.RegisterInstance(new EfDataHelper(GlobalSettings)).As <IDataHelper, IBlogSettingsLoader>();
            }
            else if (GlobalSettings.BlogDb == DbType.RAVENDB)
            {
                builder.RegisterInstance(new RavenDataHelper(GlobalSettings, HttpContext.Current.Server.MapPath(GlobalSettings.LocalDbPath))).As <IDataHelper, IBlogSettingsLoader>().SingleInstance();
            }

            if (GlobalSettings.BlogEmailMethod == EmailType.SMTP)
            {
                builder.RegisterInstance(new SmtpEmailProvider(GlobalSettings)).As <IEmailSend>();
            }
            else if (GlobalSettings.BlogEmailMethod == EmailType.API)
            {
                builder.RegisterInstance(new ApiEmailProvider(GlobalSettings)).As <IEmailSend>();
            }


            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterSource(new ViewRegistrationSource());
            container = builder.Build();

            // get dbhelper.

            IDataHelper h = container.Resolve <IDataHelper>();

            var installresult = h.CheckInstall(GlobalSettings);

            if (installresult)
            {
                RouteConfig.RegisterRoutes(RouteTable.Routes, h);

                IBlogSettingsLoader b = container.Resolve <IBlogSettingsLoader>();
                GenerateVE(b.LoadSettings().BlogTheme);


                // check for enabled plugins.

                DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
                var resolver = new AutofacWebApiDependencyResolver(container);
                GlobalConfiguration.Configuration.DependencyResolver = resolver;
            }
            else
            {
            }
            //install
        }
コード例 #3
0
        public MainWindow(ISettingsLoader settingsLoader, ISettingsSaver settingsSaver, ICommandLoader commandLoader,
                          IProgramListLoader programListLoader)
        {
            if (settingsLoader == null)
            {
                throw new ArgumentNullException(nameof(settingsLoader));
            }
            if (commandLoader == null)
            {
                throw new ArgumentNullException(nameof(commandLoader));
            }
            if (programListLoader == null)
            {
                throw new ArgumentNullException(nameof(programListLoader));
            }
            _settingsSaver = settingsSaver ?? throw new ArgumentNullException(nameof(settingsSaver));

            _validCommands    = new Dictionary <string, Command>(StringComparer.CurrentCultureIgnoreCase);
            _autocompleteList = new List <string>();
            _programPaths     = new Dictionary <string, string>(StringComparer.CurrentCultureIgnoreCase);
            //_programList = new List<string>();

            InitializeComponent();
            Activated           += CommandTb_GotFocus;
            Deactivated         += CommandTb_LostFocus;
            CommandTb.GotFocus  += CommandTb_GotFocus;
            CommandTb.LostFocus += CommandTb_LostFocus;

            try
            {
                _fUiSettings = settingsLoader.LoadSettings();
            }
            catch (SettingsLoadException e)
            {
                MessageBox.Show(
                    "Couldn't load the config/settings.json file, is it valid JSON? Re-download it or fix any JSON formatting errors.\nException: " +
                    e.BuildException());
                Application.Current.Shutdown();
            }

            foreach (var toAdd in commandLoader.GetCommands(_fUiSettings))
            {
                try
                {
                    _validCommands.Add(toAdd.Name, toAdd);
                    _autocompleteList.Add(toAdd.Name);
                }
                catch (CommandLoadException e)
                {
                    MessageBox.Show("Unable to load command.\nException is: " + e.BuildException());
                    CommandError();
                }
            }

            foreach (var cmd in _fUiSettings.Commands)
            {
                _validCommands.Add(cmd.Name, cmd);
                _autocompleteList.Add(cmd.Name);
            }

            foreach (var program in programListLoader.GetProgramList())
            {
                _programPaths[Path.GetFileNameWithoutExtension(program).Trim()] = program;
                _autocompleteList.Add(Path.GetFileNameWithoutExtension(program).Trim());
            }
        }
コード例 #4
0
 public SmtpSender(ISettingsLoader settings)
 {
     g = settings.LoadSettings();
 }