Beispiel #1
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}");
            }
        }
 /// <summary>
 /// Method to Deserialize the current inner Configuration File
 /// </summary>
 public void Deserialize()
 {
     m_definitions = m_configFileSerializer.Deserialize();
     FillOverLayerContainers(m_definitions.CubeBlocks);
 }