当前位置: 首页>>代码示例>>C#>>正文


C# Settings.GetValue方法代码示例

本文整理汇总了C#中Settings.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Settings.GetValue方法的具体用法?C# Settings.GetValue怎么用?C# Settings.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings的用法示例。


在下文中一共展示了Settings.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SongRequestsWindow

        public SongRequestsWindow(IExtension sender)
        {
            extension = sender;

            InitializeComponent();

            ini = SongRequest.ini; new Settings(extension, "Settings.ini");

            UI.CenterSpacer(RequestingRulesLabel, RequestingRulesSpacer, false, true);

            ChargeRequest.Text = "Requesting costs                       " + Currency.Name;

            ini.SetValue("Settings", "ChargeRequest", (ChargeRequest.Checked = (ini.GetValue("Settings", "ChargeRequest", "1") == "1")) ? "1" : "0");
            int variable = Convert.ToInt32(ini.GetValue("Settings", "RequestPrice", "25"));
            if (variable > RequestPrice.Maximum || variable < RequestPrice.Minimum)
            {
                variable = 25;
            }
            ini.SetValue("Settings", "RequestPrice", (RequestPrice.Value = variable).ToString());
            ini.SetValue("Settings", "LimitRequests", (LimitRequests.Checked = (ini.GetValue("Settings", "LimitRequests", "1") == "1")) ? "1" : "0");
            variable = Convert.ToInt32(ini.GetValue("Settings", "RequestsLimit", "2"));
            if (variable > RequestsLimit.Maximum || variable < RequestsLimit.Minimum)
            {
                variable = 2;
            }
            ini.SetValue("Settings", "RequestsLimit", (RequestsLimit.Value = variable).ToString());
        }
开发者ID:carriercomm,项目名称:ModBot,代码行数:27,代码来源:SongRequestsWindow.cs

示例2: Load

        public void Load()
        {
            Events.Connected += Events_Connected;
            Events.Users.UserlistRefreshed += Events_UserlistRefreshed;
            Events.Users.Added += Events_UserAdded;

            Settings = new Settings(this, "Greetings.ini");
            Settings.SetValue("Settings", "Message", Message = Settings.GetValue("Settings", "Message", "Hello {user}! Welcome to the stream!"));
            Settings.SetValue("Settings", "On", (On = (Settings.GetValue("Settings", "On", "0") == "1")) ? "1" : "0");
        }
开发者ID:carriercomm,项目名称:ModBot,代码行数:10,代码来源:Greetings.cs

示例3: UserSettings_CallingGetValueWithNullKeyWillThrowException

 public void UserSettings_CallingGetValueWithNullKeyWillThrowException()
 {
     // Arrange 
     var mockFileSystem = new Mock<IFileSystem>();
     var settings = new Settings(mockFileSystem.Object);
     // Act & Assert
     ExceptionAssert.Throws<ArgumentException>(() => settings.GetValue("SomeSection", null));
 }
开发者ID:monoman,项目名称:NugetCracker,代码行数:8,代码来源:UserSettingsTests.cs

示例4: CallingGetValueWithNullSectionWillThrowException

        public void CallingGetValueWithNullSectionWillThrowException()
        {
            // Arrange 
            var mockFileSystem = new MockFileSystem();
            var settings = new Settings(mockFileSystem);

            // Act & Assert
            ExceptionAssert.Throws<ArgumentException>(() => settings.GetValue(null, "SomeKey"));
        }
开发者ID:Redth,项目名称:nuget,代码行数:9,代码来源:SettingsTests.cs

示例5: WillGetConfigurationFromSpecifiedPath

        public void WillGetConfigurationFromSpecifiedPath()
        {
            // Arrange 
            const string configFile = "NuGet.Config";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            var config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
        <add key='key2' value='value2' />
    </SectionName>
</configuration>";
            TestFilesystemUtility.CreateConfigurationFile(configFile, mockBaseDirectory, config);

            // Act
            var settings = new Settings(mockBaseDirectory);

            // Assert 
            Assert.Equal("value1", settings.GetValue("SectionName", "key1"));
            Assert.Equal("value2", settings.GetValue("SectionName", "key2"));
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:21,代码来源:SettingsTests.cs

示例6: Load

        public void Load()
        {
            // Load what you want to do here.
            Settings settings = new Settings(this, "example.ini");  // Register a settings file.
            settings.SetValue("Example Section", "SuccessfulExample", "0"); // Set or create a value named "SuccessfulExample" under the section "Example Section", with the value "0".

            Events.Connected += Events_Connected; // Register an event handler to add our custom command.

            UI.AddWindow("Example", new ExampleWindow());

            settings.SetValue("Example Section", "SuccessfulExample", "1"); // Change the value of "SuccessfulExample" to "1".
            string Example = settings.GetValue("Example Section", "SuccessfulExample", "0"); // Check the value of "SuccessfulExample", if "SuccessfulExample" is missing, use a default value of "0".
            if (Example == "1") // Check if "SuccessfulExample" under "Example Section" is "1".
            {
                Console.WriteLine("Successful example, hurray!"); // Print this message to the console if "SuccessfulExample" has been "1".
            }
        }
开发者ID:carriercomm,项目名称:ModBot,代码行数:17,代码来源:Example.cs

示例7: OnPageLoad

    protected override void OnPageLoad()
    {
      try
      {
        // Set "Status" label
        GUIPropertyManager.SetProperty("#Status", "Idle");

        // Disable "Refresh Feed" button
        btnRefresh.Disabled = true;

        // Load Settings
        Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");

        // Setup Page Title
        // ##################################################
        string strPageTitle = mpSettings.GetValue("#Plugin", "DisplayName");
        GUIPropertyManager.SetProperty("#PageTitle", ((strPageTitle.Length == 0) ? "mpNZB" : strPageTitle));
        // ##################################################

        // Setup Client
        // ##################################################
        switch (mpSettings.GetValue("#Client", "Grabber"))
        {
          case "SABnzbd":
            {
              Client = new Clients.SABnzbd(mpSettings.GetValue("#Client", "Host"), mpSettings.GetValue("#Client", "Port"), mpSettings.GetValueAsBool("#Client", "CatSelect", false), mpSettings.GetValueAsBool("#Client", "Auth", false), mpSettings.GetValue("#Client", "Username"), mpSettings.GetValue("#Client", "Password"), mpSettings.GetValue("#Client", "APIKey"), mpSettings.GetValueAsInt("#Plugin", "UpdateFrequency", 1), mpSettings.GetValueAsBool("#Plugin", "Notifications", false), mpSettings.GetValueAsInt("#Plugin", "AutoHideSeconds", 0), mpSettings.GetValueAsBool("#Client", "Https", false));

              string strVersion = Client.Version();

              if (strVersion.Length != 0)
              {
                GUIPropertyManager.SetProperty("#Status", "Idle (" + strVersion + ")");
              }
              else
              {
                GUIPropertyManager.SetProperty("#Status", "SABnzbd connection failed");
                return;
              }

              break;
            }
        }

        
        tmrStatus = new Timer();
        tmrStatus.Elapsed += new System.Timers.ElapsedEventHandler(OnTimer);
        tmrStatus.Interval = (mpSettings.GetValueAsInt("#Plugin", "UpdateFrequency", 1) * 1000);
        tmrStatus.Enabled = true;
        
        // ##################################################

        // Unload Settings
        mpSettings.Dispose();
          

        // Update Status
        Client.Visible = true;
        Client.Status();
        if (Client.Paused) { btnPause.Selected = true; }

        // Load queue
        Client.Queue(lstItems, this, true); 
        Client.ActiveView = (int)ClientView.Queue;

        // Start with parameter
        // Working at the moment:
        // "search:string to search"
        string loadParam = null;

        // check if running version of mediaportal supports loading with parameter and handle _loadParameter
        System.Reflection.FieldInfo fi = typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        if (fi != null)
        {
            loadParam = (string)fi.GetValue(this);
        }

        if (!string.IsNullOrEmpty(loadParam)) 
        {
            Log.Debug("[MPNZB] Loading with param: " + loadParam);
            string search = Regex.Match(loadParam, "search:([^|]*)").Groups[1].Value;
            if (!string.IsNullOrEmpty(search))
            {
                SelectSite("Search", search);
            }
        }

      }
      catch (Exception e) { MP.Error(e); }
    }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:89,代码来源:mpNZB.cs

示例8: GetHome

    /// <summary>
    /// If the plugin should have it's own button on the main menu of MediaPortal then it
    /// should return true to this method, otherwise if it should not be on home
    /// it should return false
    /// </summary>
    /// <param name="strButtonText">text the button should have</param>
    /// <param name="strButtonImage">image for the button, or empty for default</param>
    /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
    /// <param name="strPictureImage">subpicture for the button or empty for none</param>
    /// <returns>true : plugin needs it's own button on home
    /// false : plugin does not need it's own button on home</returns>

    public bool GetHome(out string strButtonText, out string strButtonImage,
      out string strButtonImageFocus, out string strPictureImage)
    {
      // ##################################################
      // Load button text
      // ##################################################
      Settings mpSettings = new Settings(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + @"\mpNZB.xml");
      strButtonText = mpSettings.GetValue("#Plugin", "DisplayName");
      if (strButtonText.Length == 0) { strButtonText = "mpNZB"; }
      mpSettings.Dispose();
      // ##################################################

      strButtonImage = String.Empty;
      strButtonImageFocus = String.Empty;
      strPictureImage = String.Empty;
      return true;
    }
开发者ID:DustinBrett,项目名称:mpNZB,代码行数:29,代码来源:mpNZB.cs

示例9: InitLogger

        private void InitLogger()
        {
            var loggingConfiguration = LogManager.Configuration ?? new LoggingConfiguration();
              try
              {
            var fileInfo = new FileInfo(Config.GetFile((Config.Dir) 1, LogFileName));
            if (fileInfo.Exists)
            {
              if (File.Exists(Config.GetFile((Config.Dir) 1, OldLogFileName)))
            File.Delete(Config.GetFile((Config.Dir) 1, OldLogFileName));
              fileInfo.CopyTo(Config.GetFile((Config.Dir) 1, OldLogFileName));
              fileInfo.Delete();
            }
              }
              catch { }

              var fileTarget = new FileTarget();
              fileTarget.FileName = Config.GetFile((Config.Dir) 1, LogFileName);
              fileTarget.Encoding = "utf-8";
              fileTarget.Layout = "${date:format=dd-MMM-yyyy HH\\:mm\\:ss} ${level:fixedLength=true:padding=5} [${logger:fixedLength=true:padding=20:shortName=true}]: ${message} ${exception:format=tostring}";
              loggingConfiguration.AddTarget("file", fileTarget);
              var settings = new Settings(Config.GetFile((Config.Dir) 10, "MediaPortal.xml"));
              var str = settings.GetValue("general", "ThreadPriority");
              FHThreadPriority = str == null || !str.Equals("Normal", StringComparison.CurrentCulture) ? (str == null || !str.Equals("BelowNormal", StringComparison.CurrentCulture) ? "BelowNormal" : "Lowest") : "Lowest";
              LogLevel minLevel;
              switch ((int) (Level) settings.GetValueAsInt("general", "loglevel", 0))
              {
            case 0:
              minLevel = LogLevel.Error;
              break;
            case 1:
              minLevel = LogLevel.Warn;
              break;
            case 2:
              minLevel = LogLevel.Info;
              break;
            default:
              minLevel = LogLevel.Debug;
              break;
              }
              var loggingRule = new LoggingRule("*", minLevel, fileTarget);
              loggingConfiguration.LoggingRules.Add(loggingRule);
              LogManager.Configuration = loggingConfiguration;
        }
开发者ID:BobSilent,项目名称:mediaportal-fanart-handler,代码行数:44,代码来源:FanartHandler.cs

示例10: CallingGetValueWithSectionButNoValidKeyReturnsNull

        public void CallingGetValueWithSectionButNoValidKeyReturnsNull()
        {
            // Arrange
            var mockFileSystem = new MockFileSystem();
            var nugetConfigPath = "NuGet.Config";
            string config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
        <add key='key2' value='value2' />
    </SectionName>
</configuration>";
            mockFileSystem.AddFile(nugetConfigPath, config);
            Settings settings = new Settings(mockFileSystem);

            // Act
            var result = settings.GetValue("SectionName", "key3");

            // Assert 
            Assert.Null(result);
        }
开发者ID:Redth,项目名称:nuget,代码行数:21,代码来源:SettingsTests.cs

示例11: GetValue_IgnoresAdditionalAttributes

        public void GetValue_IgnoresAdditionalAttributes()
        {
            // Arrange
            var nugetConfigPath = "NuGet.Config";
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <SectionName>
    <add key=""key1"" value=""foo"" additional1=""some-value"" />
    <clear />
    <add key=""key2"" value=""bar"" additional2=""some-value"" someAttribute=""someAttributeValue"" />
  </SectionName>
</configuration>";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            var settings = new Settings(mockBaseDirectory);

            // Act
            var result1 = settings.GetValue("SectionName", "Key1");
            var result2 = settings.GetValue("SectionName", "Key2");

            // Assert
            Assert.Null(result1);
            Assert.Equal("bar", result2);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:24,代码来源:SettingsTests.cs

示例12: CallingGetValueWithNullKeyWillThrowException

        public void CallingGetValueWithNullKeyWillThrowException()
        {
            // Arrange
            const string configFile = "NuGet.Config";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(configFile, mockBaseDirectory, @"<configuration></configuration>");
            var settings = new Settings(mockBaseDirectory);

            // Act & Assert
            Exception ex = Record.Exception(() => settings.GetValue("SomeSection", null));
            Assert.NotNull(ex);
            var tex = Assert.IsAssignableFrom<ArgumentException>(ex);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:13,代码来源:SettingsTests.cs

示例13: CallingGetValueWithSectionAndKeyReturnsValue

        public void CallingGetValueWithSectionAndKeyReturnsValue()
        {
            // Arrange
            var nugetConfigPath = "NuGet.Config";
            var config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
    </SectionName>
    <SectionNameTwo>
        <add key='key2' value='value2' />
    </SectionNameTwo>
</configuration>";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act
            var result1 = settings.GetValue("SectionName", "key1");
            var result2 = settings.GetValue("SectionNameTwo", "key2");

            // Assert 
            Assert.Equal("value1", result1);
            Assert.Equal("value2", result2);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:25,代码来源:SettingsTests.cs

示例14: CallingGetValueWithSectionButNoValidKeyReturnsNull

        public void CallingGetValueWithSectionButNoValidKeyReturnsNull()
        {
            // Arrange
            var nugetConfigPath = "NuGet.Config";
            var config = @"
<configuration>
    <SectionName>
        <add key='key1' value='value1' />
        <add key='key2' value='value2' />
    </SectionName>
</configuration>";
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            TestFilesystemUtility.CreateConfigurationFile(nugetConfigPath, mockBaseDirectory, config);
            Settings settings = new Settings(mockBaseDirectory);

            // Act
            var result = settings.GetValue("SectionName", "key3");

            // Assert 
            Assert.Null(result);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:21,代码来源:SettingsTests.cs

示例15: GetValueResolvesRelativePaths

        public void GetValueResolvesRelativePaths()
        {
            // Arrange
            var mockBaseDirectory = TestFilesystemUtility.CreateRandomTestFolder();
            var config = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
  <SectionName>
    <add key=""path-key"" value=""..\Blah"" />
  </SectionName>
</configuration>";
            TestFilesystemUtility.CreateConfigurationFile("nuget.config", mockBaseDirectory, config);
            var settings = new Settings(mockBaseDirectory, "nuget.config");

            // Act
            string result = settings.GetValue("SectionName", "path-key", isPath: true);

            // Assert

            Assert.Equal(String.Format(@"{0}\..\Blah", mockBaseDirectory), result);
        }
开发者ID:eerhardt,项目名称:NuGet3,代码行数:20,代码来源:SettingsTests.cs


注:本文中的Settings.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。