public void ReadTest( )
        {
            string inputStr =
                "MaxComputerCount:1\r\n" +
                "MaxMatchCount:2\r\n" +
                "MaxComboItems:3\r\n" +
                "ResetSize:1280,1024\r\n" +
                "ResetPosition:0,1,-1280,150,-80,950\r\n" +
                "ResetBpp:16\r\n" +
                // "Regex*" should be added to the Regex string array.
                @"Regex_Ip:\d+\.\d+\.\d+\.\d+" + "\r\n" +
                @"Regex_Devlab:[a-zA-Z]+\d+" + "\r\n";

            using ( StringReader reader = new StringReader( inputStr ) )
            {
                ConfigFileSerializer serializer = new ConfigFileSerializer();
                serializer.Read( reader );
            }

            Assert.AreEqual( 1, Config.MaxComputerCount );
            Assert.AreEqual( 2, Config.MaxMatchCount );
            Assert.AreEqual( 3, Config.MaxComboItems );
            Assert.AreEqual( new System.Drawing.Size( 1280, 1024 ), Config.ResetSize );
            Assert.AreEqual( "0,1,-1280,150,-80,950", Config.ResetPosition );
            Assert.AreEqual( 16, Config.ResetBpp );
            Assert.AreEqual( @"\d+\.\d+\.\d+\.\d+", Config.Regex[0] );
            Assert.AreEqual( @"[a-zA-Z]+\d+", Config.Regex[1] );
        }
Beispiel #2
0
        public static void Load()
        {
            var rawContent = ConfigFileSerializer.Deserialize();

            WalletFilePath = rawContent.WalletFilePath;

            if (rawContent.Network == null)
            {
                throw new NotSupportedException($"Network is missing from {ConfigFileSerializer.ConfigFilePath}");
            }
            string networkString = rawContent.Network.Trim();

            if (networkString == "")
            {
                throw new NotSupportedException($"Network is missing from {ConfigFileSerializer.ConfigFilePath}");
            }
            else if ("mainnet".Equals(networkString, StringComparison.OrdinalIgnoreCase) ||
                     "main".Equals(networkString, StringComparison.OrdinalIgnoreCase))
            {
                Network = Network.Main;
            }
            else if ("testnet".Equals(networkString, StringComparison.OrdinalIgnoreCase) ||
                     "test".Equals(networkString, StringComparison.OrdinalIgnoreCase))
            {
                Network = Network.TestNet;
            }
            else
            {
                throw new NotSupportedException($"Wrong Network is specified in {ConfigFileSerializer.ConfigFilePath}");
            }

            if (rawContent.CanSpendUnconfirmed == null)
            {
                throw new NotSupportedException($"CanSpendUnconfirmed is missing from {ConfigFileSerializer.ConfigFilePath}");
            }
            string canSpendUnconfirmedString = rawContent.CanSpendUnconfirmed.Trim();

            if (canSpendUnconfirmedString == "")
            {
                throw new NotSupportedException($"CanSpendUnconfirmed is missing from {ConfigFileSerializer.ConfigFilePath}");
            }
            else if ("true".Equals(canSpendUnconfirmedString, StringComparison.OrdinalIgnoreCase) ||
                     "yes".Equals(canSpendUnconfirmedString, StringComparison.OrdinalIgnoreCase) ||
                     "fuckyeah".Equals(canSpendUnconfirmedString, StringComparison.OrdinalIgnoreCase) ||
                     "1" == canSpendUnconfirmedString)
            {
                CanSpendUnconfirmed = true;
            }
            else if ("false".Equals(canSpendUnconfirmedString, StringComparison.OrdinalIgnoreCase) ||
                     "no".Equals(canSpendUnconfirmedString, StringComparison.OrdinalIgnoreCase) ||
                     "nah".Equals(canSpendUnconfirmedString, StringComparison.OrdinalIgnoreCase) ||
                     "0" == canSpendUnconfirmedString)
            {
                CanSpendUnconfirmed = false;
            }
            else
            {
                throw new NotSupportedException($"Wrong CanSpendUnconfirmed value in {ConfigFileSerializer.ConfigFilePath}");
            }
        }
Beispiel #3
0
 public static void Save()
 {
     ConfigFileSerializer.Serialize(
         WalletFilePath,
         Network.ToString(),
         CanSpendUnconfirmed.ToString());
     Load();
 }
 /// <summary>
 /// Default RAII constructor of Manager
 /// </summary>
 /// <param name="cubeBlocksFileInfo">The valid FileInfo that points to a valid CubeBlocks.sbc file</param>
 /// <param name="defaultName">Defines if the file has the defaultName: CubeBlocks.sbc</param>
 public BlocksManager(FileInfo cubeBlocksFileInfo, bool defaultName = true)
 {
     if (defaultName)
     {
         if (cubeBlocksFileInfo.Name != m_DefaultFileName)
         {
             throw new SEConfigurationException(SEConfigurationExceptionState.InvalidDefaultConfigFileName, "The given file name is not matching the default configuration name pattern: CubeBlocks.sbc");
         }
     }
     m_configFileSerializer = new ConfigFileSerializer(cubeBlocksFileInfo, defaultName);
     if (cubeBlocksFileInfo.Exists)
     {
         Deserialize();
     }
 }
		/// <summary>
		/// Default RAII constructor of Manager
		/// </summary>
		/// <param name="cubeBlocksFileInfo">The valid FileInfo that points to a valid CubeBlocks.sbc file</param>
		/// <param name="defaultName">Defines if the file has the defaultName: CubeBlocks.sbc</param>
		public BlocksManager(FileInfo cubeBlocksFileInfo, bool defaultName = true)
		{
			if (defaultName)
			{
				if (cubeBlocksFileInfo.Name != m_DefaultFileName)
				{
					throw new SEConfigurationException(SEConfigurationExceptionState.InvalidDefaultConfigFileName, "The given file name is not matching the default configuration name pattern: CubeBlocks.sbc");
				}
			}
			m_configFileSerializer = new ConfigFileSerializer(cubeBlocksFileInfo, defaultName);
			if (cubeBlocksFileInfo.Exists)
			{
				Deserialize();
			}
		}
        public void LoadInitData( )
        {
            var config = new ConfigFileSerializer();
            config.Read();

            m_RecentComputerList = LoadRecentComputerList();

            OnComputerListUpdated();
        }