mirror of
https://github.com/hirschmann/nbfc
synced 2025-08-22 01:49:34 +00:00
Improve code quality
This commit is contained in:
parent
a6300cca1c
commit
8f06e589c6
@ -7,7 +7,7 @@ using System.Xml.Serialization;
|
||||
|
||||
namespace StagWare.Configurations
|
||||
{
|
||||
public class ConfigManager<T> where T : ICloneable
|
||||
public class ConfigManager<T> where T : ICloneable, new()
|
||||
{
|
||||
#region Constants
|
||||
|
||||
@ -26,9 +26,9 @@ namespace StagWare.Configurations
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private IFileSystem fs;
|
||||
private Dictionary<string, Lazy<T>> configs;
|
||||
private XmlSerializer serializer;
|
||||
private readonly IFileSystem fs;
|
||||
private readonly Dictionary<string, Lazy<T>> configs;
|
||||
private readonly XmlSerializer serializer;
|
||||
private readonly string configDirPath;
|
||||
private readonly string configFileExtension;
|
||||
|
||||
|
@ -23,7 +23,11 @@ namespace StagWare.FanControl.Configurations.Validation
|
||||
|
||||
case ValidationResult.Warning:
|
||||
summary.Warnings.Add(validation);
|
||||
if (failOnWarnings) summary.Success = false;
|
||||
|
||||
if (failOnWarnings)
|
||||
{
|
||||
summary.Success = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ValidationResult.Error:
|
||||
|
@ -56,8 +56,8 @@ namespace StagWare.FanControl.Plugins
|
||||
private void SelectPlugin()
|
||||
{
|
||||
OperatingSystem os = Environment.OSVersion;
|
||||
var platform = SupportedPlatforms.None;
|
||||
var arch = SupportedCpuArchitectures.None;
|
||||
SupportedPlatforms platform;
|
||||
SupportedCpuArchitectures arch;
|
||||
|
||||
switch (os.Platform)
|
||||
{
|
||||
|
@ -1,20 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
LOCK_FILE="/run/nbfc.pid"
|
||||
|
||||
|
||||
case $1 in
|
||||
"start")
|
||||
DIR=`dirname -- $0`
|
||||
DIR=$(dirname -- $0)
|
||||
mono-service -l:$LOCK_FILE -m:NbfcService "$DIR/NbfcService.exe"
|
||||
;;
|
||||
"stop")
|
||||
kill -SIGTERM `cat $LOCK_FILE`
|
||||
kill -SIGTERM $(cat $LOCK_FILE)
|
||||
;;
|
||||
"pause")
|
||||
kill -SIGUSR1 `cat $LOCK_FILE`
|
||||
kill -SIGUSR1 $(cat $LOCK_FILE)
|
||||
;;
|
||||
"continue")
|
||||
kill -SIGUSR2 `cat $LOCK_FILE`
|
||||
kill -SIGUSR2 $(cat $LOCK_FILE)
|
||||
;;
|
||||
*)
|
||||
echo "$0 (start|stop|pause|continue)"
|
||||
|
@ -13,14 +13,14 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class Constructor
|
||||
{
|
||||
[Fact]
|
||||
public void ThrowsIfConfigsDirIsNull()
|
||||
public static void ThrowsIfConfigsDirIsNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
() => new ConfigManager<FanControlConfigV2>(null, ".xml", new MockFileSystem()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfConfigsFileExtensionIsNull()
|
||||
public static void ThrowsIfConfigsFileExtensionIsNull()
|
||||
{
|
||||
string dir = Environment.CurrentDirectory;
|
||||
Assert.Throws<ArgumentNullException>(
|
||||
@ -31,7 +31,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class GetConfig
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsExistingConfigs()
|
||||
public static void ReturnsExistingConfigs()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -50,7 +50,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsNullIfConfigDoesNotExist()
|
||||
public static void ReturnsNullIfConfigDoesNotExist()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -64,7 +64,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsNullIfIdIsNull()
|
||||
public static void ReturnsNullIfIdIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -76,7 +76,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class ConfigFileExists
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsTrueIfExists()
|
||||
public static void ReturnsTrueIfExists()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -95,7 +95,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsFalseIfNotExisting()
|
||||
public static void ReturnsFalseIfNotExisting()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -109,7 +109,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsFalseIfIdIsNull()
|
||||
public static void ReturnsFalseIfIdIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -121,7 +121,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class Contains
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsTrueIfExists()
|
||||
public static void ReturnsTrueIfExists()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -140,7 +140,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsFalseIfNotExisting()
|
||||
public static void ReturnsFalseIfNotExisting()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -154,7 +154,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsFalseIfIdIsNull()
|
||||
public static void ReturnsFalseIfIdIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -166,7 +166,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class AddConfig
|
||||
{
|
||||
[Fact]
|
||||
public void AddsValidConfigs()
|
||||
public static void AddsValidConfigs()
|
||||
{
|
||||
string extension = ".xml";
|
||||
var fs = new MockFileSystem();
|
||||
@ -190,7 +190,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsOnDuplicates()
|
||||
public static void ThrowsOnDuplicates()
|
||||
{
|
||||
string cfgName = "foo";
|
||||
|
||||
@ -204,7 +204,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfConfigIsNull()
|
||||
public static void ThrowsIfConfigIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -214,7 +214,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfIdIsNull()
|
||||
public static void ThrowsIfIdIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -224,7 +224,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfIdContainsInvalidFileNameChars()
|
||||
public static void ThrowsIfIdContainsInvalidFileNameChars()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -239,7 +239,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class RemoveConfig
|
||||
{
|
||||
[Fact]
|
||||
public void RemovesConfigs()
|
||||
public static void RemovesConfigs()
|
||||
{
|
||||
string extension = ".xml";
|
||||
var fs = new MockFileSystem();
|
||||
@ -266,7 +266,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DoesNothingIfNotExisting()
|
||||
public static void DoesNothingIfNotExisting()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -278,7 +278,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfIdIsNull()
|
||||
public static void ThrowsIfIdIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -290,7 +290,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class UpdateConfig
|
||||
{
|
||||
[Fact]
|
||||
public void UpdatesExistingConfigs()
|
||||
public static void UpdatesExistingConfigs()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -307,7 +307,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfIdNotExisting()
|
||||
public static void ThrowsIfIdNotExisting()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -317,7 +317,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfIdIsNull()
|
||||
public static void ThrowsIfIdIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -327,7 +327,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfConfigIsNull()
|
||||
public static void ThrowsIfConfigIsNull()
|
||||
{
|
||||
var cfgMan = new ConfigManager<FanControlConfigV2>(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
|
@ -11,7 +11,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class ConfigsTests
|
||||
{
|
||||
[Fact]
|
||||
public void AreConfigsValid()
|
||||
public static void AreConfigsValid()
|
||||
{
|
||||
var configMan = new FanControlConfigManager(GetConfigsDir());
|
||||
var validator = new FanControlConfigValidator();
|
||||
@ -45,7 +45,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HaveAllConfigsBeenLoaded()
|
||||
public static void HaveAllConfigsBeenLoaded()
|
||||
{
|
||||
string path = GetConfigsDir();
|
||||
var configMan = new FanControlConfigManager(path);
|
||||
|
@ -17,13 +17,13 @@ namespace StagWare.FanControl.Configurations.Tests.ExtensionMethods
|
||||
[InlineData("", "123", "")]
|
||||
[InlineData("123", "", "")]
|
||||
[InlineData("123", "2", "2")]
|
||||
public void FindsLongestSubstring(string s1, string s2, string result)
|
||||
public static void FindsLongestSubstring(string s1, string s2, string result)
|
||||
{
|
||||
Assert.Equal(result, s1.GetLongestCommonSubstring(s2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsIfStringIsNull()
|
||||
public static void ThrowsIfStringIsNull()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => "".GetLongestCommonSubstring(null));
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class SelectConfig
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsTrueAndSetsPropertiesIfExisting()
|
||||
public static void ReturnsTrueAndSetsPropertiesIfExisting()
|
||||
{
|
||||
var cfgMan = new FanControlConfigManager(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -26,7 +26,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsFalseClearsPropertiesIfNotExisting()
|
||||
public static void ReturnsFalseClearsPropertiesIfNotExisting()
|
||||
{
|
||||
var cfgMan = new FanControlConfigManager(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
@ -44,7 +44,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
public class RecommendConfigs
|
||||
{
|
||||
[Fact]
|
||||
public void ReturnsOnlyValidSuggestions()
|
||||
public static void ReturnsOnlyValidSuggestions()
|
||||
{
|
||||
string[] notebooks = new[] { "HP ProBook 1234", "HP EliteBook 1234", "Acer Foo 7683" };
|
||||
var cfgMan = new FanControlConfigManager(
|
||||
@ -77,7 +77,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DoNotRecommendConfigsWithSameRwRegisters()
|
||||
public static void DoNotRecommendConfigsWithSameRwRegisters()
|
||||
{
|
||||
string[] notebooks = new[] { "HP ProBook 1234", "HP ProBook 1235" };
|
||||
var cfgMan = new FanControlConfigManager(
|
||||
@ -102,7 +102,7 @@ namespace StagWare.FanControl.Configurations.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReturnsEmptyListIfModelIsNull()
|
||||
public static void ReturnsEmptyListIfModelIsNull()
|
||||
{
|
||||
var cfgMan = new FanControlConfigManager(
|
||||
Environment.CurrentDirectory, ".xml", new MockFileSystem());
|
||||
|
@ -8,13 +8,13 @@ namespace StagWare.FanControl.Tests
|
||||
public class Constructor
|
||||
{
|
||||
[Fact]
|
||||
public void ThrowsWithInvalidPollInterval()
|
||||
public static void ThrowsWithInvalidPollInterval()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new ArithmeticMeanTemperatureFilter(0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsWithInvalidTimespan()
|
||||
public static void ThrowsWithInvalidTimespan()
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => new ArithmeticMeanTemperatureFilter(100, 0));
|
||||
}
|
||||
@ -23,7 +23,7 @@ namespace StagWare.FanControl.Tests
|
||||
public class FilterTemperature
|
||||
{
|
||||
[Fact]
|
||||
public void RespectsTimespan()
|
||||
public static void RespectsTimespan()
|
||||
{
|
||||
int interval = 2000;
|
||||
int timespan = 6000;
|
||||
|
@ -12,7 +12,7 @@ namespace StagWare.FanControl.Tests
|
||||
public class Start
|
||||
{
|
||||
[Fact]
|
||||
public async Task CallsSetTargetSpeed()
|
||||
public static async Task CallsSetTargetSpeed()
|
||||
{
|
||||
var fanCfg = new FanConfiguration();
|
||||
var cfg = new FanControlConfigV2()
|
||||
@ -48,7 +48,7 @@ namespace StagWare.FanControl.Tests
|
||||
fanControl.Start(false);
|
||||
Assert.True(fanControl.Enabled, nameof(fanControl.Enabled));
|
||||
|
||||
await Task.WhenAny(task, Task.Delay(cfg.EcPollInterval * 3));
|
||||
await Task.WhenAny(task, Task.Delay(cfg.EcPollInterval * 3)).ConfigureAwait(false);
|
||||
|
||||
Assert.True(task.IsCompleted, nameof(task.IsCompleted));
|
||||
A.CallTo(() => fan.SetTargetSpeed(A<float>.Ignored, A<float>.Ignored, false))
|
||||
@ -57,7 +57,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RespectsReadOnlyArg()
|
||||
public static async Task RespectsReadOnlyArg()
|
||||
{
|
||||
var fanCfg = new FanConfiguration();
|
||||
var cfg = new FanControlConfigV2()
|
||||
@ -103,7 +103,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppliesRegisterWriteConfigurations()
|
||||
public static void AppliesRegisterWriteConfigurations()
|
||||
{
|
||||
var fanCfg = new FanConfiguration();
|
||||
var registerWriteCfg = new RegisterWriteConfiguration()
|
||||
@ -147,7 +147,7 @@ namespace StagWare.FanControl.Tests
|
||||
[InlineData(0)]
|
||||
[InlineData(66.66)]
|
||||
[InlineData(111)]
|
||||
public async Task CallsSetTargetSpeed(float speed)
|
||||
public static async Task CallsSetTargetSpeed(float speed)
|
||||
{
|
||||
var fanCfg1 = new FanConfiguration();
|
||||
var fanCfg2 = new FanConfiguration();
|
||||
@ -201,7 +201,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThrowsWhenIndexIsInvalid()
|
||||
public static void ThrowsWhenIndexIsInvalid()
|
||||
{
|
||||
var cfg = new FanControlConfigV2()
|
||||
{
|
||||
@ -232,7 +232,7 @@ namespace StagWare.FanControl.Tests
|
||||
public class Stop
|
||||
{
|
||||
[Fact]
|
||||
public void CallsResetOnFans()
|
||||
public static void CallsResetOnFans()
|
||||
{
|
||||
var fanCfg = new FanConfiguration()
|
||||
{
|
||||
@ -269,9 +269,8 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ResetsRegisterWriteConfigurations()
|
||||
public static void ResetsRegisterWriteConfigurations()
|
||||
{
|
||||
var fanCfg = new FanConfiguration();
|
||||
var regWriteCfg = new RegisterWriteConfiguration()
|
||||
{
|
||||
Register = 123,
|
||||
@ -283,7 +282,7 @@ namespace StagWare.FanControl.Tests
|
||||
var cfg = new FanControlConfigV2()
|
||||
{
|
||||
EcPollInterval = 100,
|
||||
FanConfigurations = { fanCfg },
|
||||
FanConfigurations = { new FanConfiguration() },
|
||||
RegisterWriteConfigurations = { regWriteCfg }
|
||||
};
|
||||
|
||||
@ -312,7 +311,7 @@ namespace StagWare.FanControl.Tests
|
||||
public class Dispose
|
||||
{
|
||||
[Fact]
|
||||
public void CallsResetOnFans()
|
||||
public static void CallsResetOnFans()
|
||||
{
|
||||
var fanCfg = new FanConfiguration()
|
||||
{
|
||||
@ -348,7 +347,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TriesToForceResetFans()
|
||||
public static void TriesToForceResetFans()
|
||||
{
|
||||
var fanCfg = new FanConfiguration()
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace StagWare.FanControl.Tests
|
||||
[InlineData(0)]
|
||||
[InlineData(66.66)]
|
||||
[InlineData(100)]
|
||||
public void CallsWriteByte(float speed)
|
||||
public static void CallsWriteByte(float speed)
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var cfg = new FanConfiguration()
|
||||
@ -39,7 +39,7 @@ namespace StagWare.FanControl.Tests
|
||||
[InlineData(0)]
|
||||
[InlineData(66.66)]
|
||||
[InlineData(100)]
|
||||
public void CallsWriteWord(float speed)
|
||||
public static void CallsWriteWord(float speed)
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var cfg = new FanConfiguration()
|
||||
@ -60,7 +60,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandlesCriticalTemperature()
|
||||
public static void HandlesCriticalTemperature()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var cfg = new FanConfiguration()
|
||||
@ -83,7 +83,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DoesRespectReadOnlyArg()
|
||||
public static void DoesRespectReadOnlyArg()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var cfg = new FanConfiguration()
|
||||
@ -106,7 +106,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HandlesAutoControl()
|
||||
public static void HandlesAutoControl()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var cfg = new FanConfiguration()
|
||||
@ -123,7 +123,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppliesFanSpeedOverrides()
|
||||
public static void AppliesFanSpeedOverrides()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var fanSpeedOverride = new FanSpeedPercentageOverride()
|
||||
@ -154,7 +154,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppliesFanSpeedOverridesWhenTempIsCritical()
|
||||
public static void AppliesFanSpeedOverridesWhenTempIsCritical()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
var fanSpeedOverride = new FanSpeedPercentageOverride()
|
||||
@ -191,7 +191,7 @@ namespace StagWare.FanControl.Tests
|
||||
public class GetCurrentSpeed
|
||||
{
|
||||
[Fact]
|
||||
public void CallsReadByte()
|
||||
public static void CallsReadByte()
|
||||
{
|
||||
var cfg = new FanConfiguration()
|
||||
{
|
||||
@ -212,7 +212,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CallsReadWord()
|
||||
public static void CallsReadWord()
|
||||
{
|
||||
var cfg = new FanConfiguration()
|
||||
{
|
||||
@ -236,7 +236,7 @@ namespace StagWare.FanControl.Tests
|
||||
public class Reset
|
||||
{
|
||||
[Fact]
|
||||
public void CallsWriteByte()
|
||||
public static void CallsWriteByte()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
A.CallTo(() => ec.AcquireLock(A<int>.Ignored)).Returns(true);
|
||||
@ -256,7 +256,7 @@ namespace StagWare.FanControl.Tests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CallsWriteWord()
|
||||
public static void CallsWriteWord()
|
||||
{
|
||||
var ec = A.Fake<IEmbeddedController>();
|
||||
A.CallTo(() => ec.AcquireLock(A<int>.Ignored)).Returns(true);
|
||||
|
@ -352,7 +352,7 @@ namespace ConfigEditor.ViewModels
|
||||
AddOrUpdateConfig(ConvertViewModelToConfig(this), cfgName);
|
||||
UpdateViewModel();
|
||||
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs()
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs
|
||||
{
|
||||
Success = true
|
||||
});
|
||||
@ -360,7 +360,7 @@ namespace ConfigEditor.ViewModels
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs()
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs
|
||||
{
|
||||
Success = false,
|
||||
Exception = e
|
||||
@ -392,7 +392,7 @@ namespace ConfigEditor.ViewModels
|
||||
var cfg = ConvertViewModelToConfig(this);
|
||||
this.configManager.UpdateConfig(this.SelectedConfigName, cfg);
|
||||
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs()
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs
|
||||
{
|
||||
Success = true
|
||||
});
|
||||
@ -400,7 +400,7 @@ namespace ConfigEditor.ViewModels
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs()
|
||||
OnSaveConfigCommandExecuted(new CommandExecutedEventArgs
|
||||
{
|
||||
Success = false,
|
||||
Exception = e
|
||||
@ -494,7 +494,7 @@ namespace ConfigEditor.ViewModels
|
||||
return Path.Combine(path, ConfigsDirectoryName);
|
||||
}
|
||||
|
||||
private bool TryLoadFanControlConfig<T>(string configFilePath, out T config)
|
||||
private static bool TryLoadFanControlConfig<T>(string configFilePath, out T config)
|
||||
where T : new()
|
||||
{
|
||||
config = default(T);
|
||||
@ -566,7 +566,7 @@ namespace ConfigEditor.ViewModels
|
||||
|
||||
private static FanControlConfigV2 ConvertViewModelToConfig(MainViewModel viewModel)
|
||||
{
|
||||
var config = new FanControlConfigV2()
|
||||
var config = new FanControlConfigV2
|
||||
{
|
||||
CriticalTemperature = viewModel.CriticalTemperature,
|
||||
EcPollInterval = viewModel.EcPollInterval,
|
||||
@ -595,7 +595,7 @@ namespace ConfigEditor.ViewModels
|
||||
|
||||
foreach (FanConfigViewModel vm in viewModels)
|
||||
{
|
||||
var cfg = new FanConfiguration()
|
||||
var cfg = new FanConfiguration
|
||||
{
|
||||
FanDisplayName = vm.FanDisplayName,
|
||||
ReadRegister = vm.ReadRegister,
|
||||
@ -612,7 +612,7 @@ namespace ConfigEditor.ViewModels
|
||||
if (vm.FanSpeedOverrides != null)
|
||||
{
|
||||
cfg.FanSpeedPercentageOverrides = vm.FanSpeedOverrides.Select(
|
||||
x => new FanSpeedPercentageOverride()
|
||||
x => new FanSpeedPercentageOverride
|
||||
{
|
||||
FanSpeedPercentage = x.FanSpeedPercentage,
|
||||
FanSpeedValue = x.FanSpeedValue,
|
||||
@ -623,7 +623,7 @@ namespace ConfigEditor.ViewModels
|
||||
if (vm.TemperatureThresholds != null)
|
||||
{
|
||||
cfg.TemperatureThresholds = vm.TemperatureThresholds.Select(
|
||||
x => new TemperatureThreshold()
|
||||
x => new TemperatureThreshold
|
||||
{
|
||||
DownThreshold = x.DownThreshold,
|
||||
UpThreshold = x.UpThreshold,
|
||||
@ -641,7 +641,7 @@ namespace ConfigEditor.ViewModels
|
||||
IEnumerable<RegisterWriteConfigViewModel> viewModels)
|
||||
{
|
||||
return viewModels.Select(
|
||||
x => new RegisterWriteConfiguration()
|
||||
x => new RegisterWriteConfiguration
|
||||
{
|
||||
Description = x.Description,
|
||||
Register = x.Register,
|
||||
@ -710,7 +710,7 @@ namespace ConfigEditor.ViewModels
|
||||
|
||||
foreach (FanConfiguration cfg in configs)
|
||||
{
|
||||
var vm = new FanConfigViewModel()
|
||||
var vm = new FanConfigViewModel
|
||||
{
|
||||
FanDisplayName = cfg.FanDisplayName,
|
||||
ReadRegister = cfg.ReadRegister,
|
||||
@ -727,7 +727,7 @@ namespace ConfigEditor.ViewModels
|
||||
if (cfg.FanSpeedPercentageOverrides != null)
|
||||
{
|
||||
vm.FanSpeedOverrides = new ObservableCollection<FanSpeedOverrideViewModel>(
|
||||
cfg.FanSpeedPercentageOverrides.Select(x => new FanSpeedOverrideViewModel()
|
||||
cfg.FanSpeedPercentageOverrides.Select(x => new FanSpeedOverrideViewModel
|
||||
{
|
||||
FanSpeedPercentage = x.FanSpeedPercentage,
|
||||
FanSpeedValue = x.FanSpeedValue,
|
||||
@ -738,7 +738,7 @@ namespace ConfigEditor.ViewModels
|
||||
if (cfg.TemperatureThresholds != null)
|
||||
{
|
||||
vm.TemperatureThresholds = new ObservableCollection<TemperatureThresholdViewModel>(
|
||||
cfg.TemperatureThresholds.Select(x => new TemperatureThresholdViewModel()
|
||||
cfg.TemperatureThresholds.Select(x => new TemperatureThresholdViewModel
|
||||
{
|
||||
UpThreshold = x.UpThreshold,
|
||||
DownThreshold = x.DownThreshold,
|
||||
@ -755,7 +755,7 @@ namespace ConfigEditor.ViewModels
|
||||
private static IEnumerable<RegisterWriteConfigViewModel> ConvertRegisterWriteConfigsToViewModels(
|
||||
IEnumerable<RegisterWriteConfiguration> configs)
|
||||
{
|
||||
return configs.Select(x => new RegisterWriteConfigViewModel()
|
||||
return configs.Select(x => new RegisterWriteConfigViewModel
|
||||
{
|
||||
Description = x.Description,
|
||||
Register = x.Register,
|
||||
|
@ -42,12 +42,12 @@ namespace ConfigEditor.Windows
|
||||
|
||||
if (dataContext != null)
|
||||
{
|
||||
var viewModel = new TemperatureThresholdViewModel()
|
||||
var viewModel = new TemperatureThresholdViewModel
|
||||
{
|
||||
Parent = dataContext
|
||||
};
|
||||
|
||||
var dialog = new TemperatureThresholdWindow()
|
||||
var dialog = new TemperatureThresholdWindow
|
||||
{
|
||||
DataContext = viewModel,
|
||||
Owner = this
|
||||
@ -75,7 +75,7 @@ namespace ConfigEditor.Windows
|
||||
var clonedViewModel = viewModel.Clone() as TemperatureThresholdViewModel;
|
||||
clonedViewModel.Parent = dataContext;
|
||||
|
||||
var dialog = new TemperatureThresholdWindow()
|
||||
var dialog = new TemperatureThresholdWindow
|
||||
{
|
||||
DataContext = clonedViewModel,
|
||||
Owner = this
|
||||
@ -106,7 +106,7 @@ namespace ConfigEditor.Windows
|
||||
if (dataContext != null)
|
||||
{
|
||||
dataContext.TemperatureThresholds = new ObservableCollection<TemperatureThresholdViewModel>(
|
||||
FanConfiguration.DefaultTemperatureThresholds.Select(x => new TemperatureThresholdViewModel()
|
||||
FanConfiguration.DefaultTemperatureThresholds.Select(x => new TemperatureThresholdViewModel
|
||||
{
|
||||
DownThreshold = x.DownThreshold,
|
||||
UpThreshold = x.UpThreshold,
|
||||
@ -133,12 +133,12 @@ namespace ConfigEditor.Windows
|
||||
|
||||
if (dataContext != null)
|
||||
{
|
||||
var viewModel = new FanSpeedOverrideViewModel()
|
||||
var viewModel = new FanSpeedOverrideViewModel
|
||||
{
|
||||
Parent = dataContext
|
||||
};
|
||||
|
||||
var dialog = new FanSpeedOverrideWindow()
|
||||
var dialog = new FanSpeedOverrideWindow
|
||||
{
|
||||
DataContext = viewModel,
|
||||
Owner = this
|
||||
@ -185,7 +185,7 @@ namespace ConfigEditor.Windows
|
||||
var clonedViewModel = viewModel.Clone() as FanSpeedOverrideViewModel;
|
||||
clonedViewModel.Parent = dataContext;
|
||||
|
||||
var dialog = new FanSpeedOverrideWindow()
|
||||
var dialog = new FanSpeedOverrideWindow
|
||||
{
|
||||
DataContext = clonedViewModel,
|
||||
Owner = this
|
||||
|
@ -50,14 +50,14 @@ namespace ConfigEditor.Windows
|
||||
InitializeComponent();
|
||||
|
||||
this.MessageBoxErrorStyle = new Style(typeof(Xceed.Wpf.Toolkit.MessageBox));
|
||||
this.MessageBoxErrorStyle.Setters.Add(new Setter()
|
||||
this.MessageBoxErrorStyle.Setters.Add(new Setter
|
||||
{
|
||||
Property = Xceed.Wpf.Toolkit.MessageBox.ImageSourceProperty,
|
||||
Value = SystemIcons.Error.ToImageSource()
|
||||
});
|
||||
|
||||
this.MessageBoxInfoStyle = new Style(typeof(Xceed.Wpf.Toolkit.MessageBox));
|
||||
this.MessageBoxInfoStyle.Setters.Add(new Setter()
|
||||
this.MessageBoxInfoStyle.Setters.Add(new Setter
|
||||
{
|
||||
Property = Xceed.Wpf.Toolkit.MessageBox.ImageSourceProperty,
|
||||
Value = SystemIcons.Information.ToImageSource()
|
||||
@ -156,7 +156,7 @@ namespace ConfigEditor.Windows
|
||||
var clonedViewModel = (FanConfigViewModel)vm.Clone();
|
||||
clonedViewModel.Parent = dc;
|
||||
|
||||
var wnd = new FanConfigWindow()
|
||||
var wnd = new FanConfigWindow
|
||||
{
|
||||
DataContext = clonedViewModel,
|
||||
Owner = this
|
||||
@ -175,7 +175,7 @@ namespace ConfigEditor.Windows
|
||||
{
|
||||
var clonedViewModel = vm.Clone() as RegisterWriteConfigViewModel;
|
||||
|
||||
var wnd = new RegisterWriteConfigWindow()
|
||||
var wnd = new RegisterWriteConfigWindow
|
||||
{
|
||||
DataContext = clonedViewModel,
|
||||
Owner = this
|
||||
@ -193,7 +193,7 @@ namespace ConfigEditor.Windows
|
||||
|
||||
void vm_RequestingConfigName(object sender, DialogEventArgs<RequestConfigNameViewModel> e)
|
||||
{
|
||||
var dialog = new RequestConfigNameWindow()
|
||||
var dialog = new RequestConfigNameWindow
|
||||
{
|
||||
DataContext = e.ViewModel,
|
||||
Owner = this
|
||||
@ -207,7 +207,7 @@ namespace ConfigEditor.Windows
|
||||
|
||||
void vm_RequestingConfigPath(object sender, DialogEventArgs<RequestConfigPathViewModel> e)
|
||||
{
|
||||
var dialog = new System.Windows.Forms.OpenFileDialog()
|
||||
var dialog = new System.Windows.Forms.OpenFileDialog
|
||||
{
|
||||
CheckFileExists = true,
|
||||
CheckPathExists = true,
|
||||
@ -290,12 +290,12 @@ namespace ConfigEditor.Windows
|
||||
|
||||
if (dc != null)
|
||||
{
|
||||
var vm = new FanConfigViewModel()
|
||||
var vm = new FanConfigViewModel
|
||||
{
|
||||
Parent = dc
|
||||
};
|
||||
|
||||
var wnd = new FanConfigWindow()
|
||||
var wnd = new FanConfigWindow
|
||||
{
|
||||
DataContext = vm,
|
||||
Owner = this
|
||||
@ -340,7 +340,7 @@ namespace ConfigEditor.Windows
|
||||
if (dc != null)
|
||||
{
|
||||
var vm = new RegisterWriteConfigViewModel();
|
||||
var wnd = new RegisterWriteConfigWindow()
|
||||
var wnd = new RegisterWriteConfigWindow
|
||||
{
|
||||
DataContext = vm,
|
||||
Owner = this
|
||||
|
@ -127,7 +127,6 @@
|
||||
<Compile Include="Services\FanControlStatusChangedEventArgs.cs" />
|
||||
<Compile Include="Services\IFanControlClient.cs" />
|
||||
<Compile Include="Messages\OpenSelectConfigDialogMessage.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="TrayIconRenderer.cs" />
|
||||
<Compile Include="UserControls\BindableTaskbarIcon.cs" />
|
||||
<Compile Include="UserControls\FanController.xaml.cs">
|
||||
|
@ -44,7 +44,7 @@ namespace NbfcClient.Services
|
||||
{
|
||||
}
|
||||
|
||||
public FanControlClient(int updateInterval = 3000)
|
||||
public FanControlClient(int updateInterval)
|
||||
{
|
||||
fanControlInfo = new FanControlInfo();
|
||||
timer = new DispatcherTimer();
|
||||
|
@ -1,28 +0,0 @@
|
||||
namespace NbfcClient.Properties {
|
||||
|
||||
|
||||
// Diese Klasse ermöglicht die Behandlung bestimmter Ereignisse der Einstellungsklasse:
|
||||
// Das SettingChanging-Ereignis wird ausgelöst, bevor der Wert einer Einstellung geändert wird.
|
||||
// Das PropertyChanged-Ereignis wird ausgelöst, nachdem der Wert einer Einstellung geändert wurde.
|
||||
// Das SettingsLoaded-Ereignis wird ausgelöst, nachdem die Einstellungswerte geladen wurden.
|
||||
// Das SettingsSaving-Ereignis wird ausgelöst, bevor die Einstellungswerte gespeichert werden.
|
||||
internal sealed partial class Settings {
|
||||
|
||||
public Settings() {
|
||||
// // Heben Sie die Auskommentierung der unten angezeigten Zeilen auf, um Ereignishandler zum Speichern und Ändern von Einstellungen hinzuzufügen:
|
||||
//
|
||||
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||
//
|
||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||
//
|
||||
}
|
||||
|
||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||
// Fügen Sie hier Code zum Behandeln des SettingChangingEvent-Ereignisses hinzu.
|
||||
}
|
||||
|
||||
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
// Fügen Sie hier Code zum Behandeln des SettingsSaving-Ereignisses hinzu.
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using NbfcClient.Messages;
|
||||
using NbfcClient.Properties;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
@ -24,7 +23,7 @@ namespace NbfcClient.Windows
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private DispatcherTimer saveSizeTimer;
|
||||
private readonly DispatcherTimer saveSizeTimer;
|
||||
private bool close;
|
||||
private double lastWidth;
|
||||
private double lastHeight;
|
||||
@ -82,13 +81,13 @@ namespace NbfcClient.Windows
|
||||
|
||||
private void ShowSelectConfigDialog(OpenSelectConfigDialogMessage msg)
|
||||
{
|
||||
var dialog = new SelectConfigWindow() { Owner = this };
|
||||
var dialog = new SelectConfigWindow { Owner = this };
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
private void ShowSettingsDialog(OpenSettingsDialogMessage msg)
|
||||
{
|
||||
var dialog = new SettingsWindow() { Owner = this };
|
||||
var dialog = new SettingsWindow { Owner = this };
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user