public void XmlDocFilenameReturnsValue() { string fileName = "Core\\guilib\\TestData\\MediaPortal.xml"; XmlSettingsProvider doc = new XmlSettingsProvider(fileName); Assert.AreEqual(fileName, doc.FileName); }
public void Prefetch1() { string xml = @"<?xml version=""1.0"" encoding=""utf-8""?> <profile> <section name=""capture""> <entry name=""tuner"">Cable</entry> </section> </profile> "; using (TextWriter writer = File.CreateText("prefetchtest.xml")) { writer.Write(xml); } XmlSettingsProvider provider = new XmlSettingsProvider("prefetchtest.xml"); provider.Prefetch(this.Remember); Assert.AreEqual("capture", rememberedSettings[0][0]); Assert.AreEqual("tuner", rememberedSettings[0][1]); Assert.AreEqual("Cable", rememberedSettings[0][2]); }
public Startup(string[] arguments) { Thread.CurrentThread.Name = "Config Main"; Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; // Logger should write into Configuration.log Log.SetConfigurationMode(); Log.BackupLogFile(LogType.Config); FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath); Log.Info("Configuration v" + versionInfo.FileVersion + " is starting up on " + OSInfo.OSInfo.GetOSDisplayVersion()); #if DEBUG Log.Info("Debug build: " + Application.ProductVersion); #else Log.Info("Build: " + Application.ProductVersion); #endif //Check for unsupported operating systems OSPrerequisites.OSPrerequisites.OsCheck(true); Log.Info("Verifying DirectX 9"); if (!DirectXCheck.IsInstalled()) { string strLine = "Please install a newer DirectX 9.0c redist!\r\n"; strLine = strLine + "MediaPortal cannot run without DirectX 9.0c redist (August 2008)\r\n"; strLine = strLine + "http://install.team-mediaportal.com/DirectX"; MessageBox.Show(strLine, "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Log.Info("Using Directories:"); foreach (string options in Enum.GetNames(typeof (Config.Dir))) { Log.Info("{0} - {1}", options, Config.GetFolder((Config.Dir) Enum.Parse(typeof (Config.Dir), options))); } // rtv: disabled Wizard due to frequent bug reports on serveral sections. // please fix those before re-enabling. // //if (!File.Exists(Config.GetFile(Config.Dir.Config, "mediaportal.xml"))) // startupMode = StartupMode.Wizard; //else if (arguments != null) { foreach (string argument in arguments) { string trimmedArgument = argument.ToLowerInvariant(); if (trimmedArgument.StartsWith("/wizard")) { //startupMode = StartupMode.Wizard; //Log.Debug("Startup: Argument did request Wizard mode - {0}", trimmedArgument); Log.Warn("Startup: Wizard mode invoked but currently disabled: argument ignored!"); } if (trimmedArgument.StartsWith("/section")) { string[] subArguments = argument.Split('='); if (subArguments.Length >= 2) { sectionsConfiguration = subArguments[1]; } } // deploymode used to upgrade the configuration files if (trimmedArgument == "--deploymode") { Log.Info("Running in deploy mode - upgrading config file"); try { ISettingsProvider mpConfig = new XmlSettingsProvider(MPSettings.ConfigPathName); SettingsUpgradeManager.Instance.UpgradeToLatest(mpConfig); SettingsUpgradeManager.Instance.ApplyDeploySettingUpgrade(mpConfig); } catch (Exception ex) { Log.Error("Unhandled exception when upgrading config file '" + MPSettings.ConfigPathName + "'\r\n\r\n" + ex.ToString()); } finally { _preventGUILaunch = true; } } if (trimmedArgument == "/debugoptions") { _debugOptions = true; } if (trimmedArgument.ToLowerInvariant() == "/avoidversioncheck") { _avoidVersionChecking = true; Log.Warn("Version check is disabled by command line switch \"/avoidVersionCheck\""); } } } // we are not in deploy mode but there is not mediaportal.xml file // create one and apply any updates from deploy.xml if (!_preventGUILaunch && !File.Exists(Config.GetFile(Config.Dir.Config, "mediaportal.xml"))) { Log.Info("mediaportal.xml does not exist. Creating a new file and applying deploy tool parameters"); SettingsUpgradeManager.Instance.ApplyDeploySetting(); } }