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


C# IConfiguration.GetValue方法代码示例

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


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

示例1: RippleApi

        internal RippleApi(IConfiguration config, ILogger logger, IFeeProvider feeProvider, ITransactionSigner txSigner, string dataApiUrl, string exchIssuerAddress, string fiatCurrencyCode)
        {
            _config = config;
            _logger = logger;
            _feeProvider = feeProvider;
            _txSigner = txSigner;
            _dataApiUrl = dataApiUrl;
            _issuerAddress = exchIssuerAddress;
            _fiatCurreny = fiatCurrencyCode;
            _walletAddress = _config.AccessKey;

            _webSocket = new WebSocket(_rippleSocketUri = _config.GetValue("server"));

            string proxyHost = _config.GetValue("proxyHost");
            string proxyPort = _config.GetValue("proxyPort");
            if (null != proxyHost && null != proxyPort)
            {
                //TODO: these two lines don't belong here, rather to WebClient2
                _webProxy = new WebProxy(proxyHost, int.Parse(proxyPort));
                _webProxy.Credentials = CredentialCache.DefaultCredentials;

                var wsProxy = new HttpConnectProxy(new DnsEndPoint(proxyHost, Int32.Parse(proxyPort)), "1.0");
                _webSocket.Proxy = wsProxy;
            }

            _webSocket.Opened += websocket_Opened;
            _webSocket.Error += websocket_Error;
            _webSocket.Closed += websocket_Closed;
            _webSocket.MessageReceived += websocket_MessageReceived;
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:30,代码来源:RippleApi.cs

示例2: DefaultSenderConfiguration

        public DefaultSenderConfiguration(IConfiguration configuration)
        {
            m_address = configuration.GetValue(APP_KEY_FROM_ADDRESS);
            m_name = configuration.GetValue(APP_KEY_FROM_NAME);

            if (string.IsNullOrWhiteSpace(m_address))
            {
                throw new ConfigurationMissingException(APP_KEY_FROM_ADDRESS);
            }
        }
开发者ID:aduggleby,项目名称:dragon,代码行数:10,代码来源:DefaultSenderConfiguration.cs

示例3: CoinsBankApi

        OrderInfoResponse _dummySellOrder; //TODO: DELETE THESE TWO LINES

        #endregion Fields

        #region Constructors

        internal CoinsBankApi(IConfiguration config, ILogger logger, string baseAsset, string counterAsset)
        {
            _config = config;
            _logger = logger;
            _baseAsset = baseAsset.ToUpperInvariant();
            _counterAsset = counterAsset.ToUpperInvariant();
            _dataBaseUrl = config.GetValue("data_api_url");
            _tradeBaseUrl = config.GetValue("trading_base_url");

            _hashMaker = new HMACSHA512(Encoding.ASCII.GetBytes(_config.SecretKey));
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:17,代码来源:CoinsBankApi.cs

示例4: BtcChinaApi

 internal BtcChinaApi(IConfiguration config, ILogger logger)
 {
     _config = config;
     _logger = logger;
     var proxyHost = _config.GetValue("proxyHost");
     var proxyPort = _config.GetValue("proxyPort");
     if (null != proxyHost && null != proxyPort)
     {
         _webProxy = new WebProxy(proxyHost, int.Parse(proxyPort));
         _webProxy.Credentials = CredentialCache.DefaultCredentials;
     }
 }
开发者ID:rarach,项目名称:exchange-bots,代码行数:12,代码来源:BtcChinaApi.cs

示例5: LakeBtcApi

 public LakeBtcApi(IConfiguration config, ILogger logger, string baseCurrencyCode, string arbCurrencyCode)
 {
     _logger = logger;
     var proxyHost = config.GetValue("proxyHost");
     var proxyPort = config.GetValue("proxyPort");
     if (null != proxyHost && null != proxyPort)
     {
         _webProxy = new WebProxy(proxyHost, int.Parse(proxyPort));
         _webProxy.Credentials = CredentialCache.DefaultCredentials;
     }
     /*TODO:del?
     var nonceOffset = Configuration.GetValue("nonce_offset");
     if (!String.IsNullOrEmpty(nonceOffset))
         _nonceOffset = long.Parse(nonceOffset);*/
 }
开发者ID:rarach,项目名称:exchange-bots,代码行数:15,代码来源:LakeBtcApi.cs

示例6: SaveFrom

        public void SaveFrom(IConfiguration config, ConfigurationLevel level, Stream outputStream)
        {
            try {
                var keys = config.GetKeys(level);
                var properties = new Properties();

                foreach (var configKey in keys) {
                    var configValue = config.GetValue(configKey);
                    object value;
                    if (configValue == null || configValue.Value == null) {
                        value = configKey.DefaultValue;
                    } else {
                        value = configValue.Value;
                    }

                    var stringValue = Convert.ToString(value, CultureInfo.InvariantCulture);
                    properties.SetProperty(configKey.Name, stringValue);
                }

                properties.Store(outputStream, String.Empty);
            } catch (DatabaseConfigurationException) {
                throw;
            } catch (Exception ex) {
                throw new DatabaseConfigurationException("Could not save the configurations to the given stream.", ex);
            }
        }
开发者ID:furesoft,项目名称:deveeldb,代码行数:26,代码来源:PropertiesConfigFormatter.cs

示例7: FileFolderMailQueue

        public FileFolderMailQueue(
            IFileSystem fileSystem = null,
            IConfiguration configuration = null)
        {
            m_settings = new JsonSerializerSettings();
            m_settings.TypeNameHandling = TypeNameHandling.All;
            m_settings.NullValueHandling = NullValueHandling.Ignore;

            m_configuration = configuration ?? new DefaultConfiguration();

            m_fileSystem = fileSystem ?? new DefaultFileSystem();


            m_baseDirectory = m_configuration.GetValue(APP_FOLDER);
            if (string.IsNullOrWhiteSpace(m_baseDirectory))
            {
                throw new ConfigurationMissingException(APP_FOLDER);
            }

            if (!m_fileSystem.ExistDir(m_baseDirectory))
            {
                throw new Exception(string.Format("Directory '{0}' does not exist. Cannot continue.",
                    m_baseDirectory));
            }

            m_fileSystem.CreateDir(m_queueDir = Path.Combine(m_baseDirectory, FOLDER_QUEUE));
            m_fileSystem.CreateDir(m_sentDir = Path.Combine(m_baseDirectory, FOLDER_SENT));
            m_fileSystem.CreateDir(m_errorDir = Path.Combine(m_baseDirectory, FOLDER_ERROR));
            m_fileSystem.CreateDir(m_workerDir = Path.Combine(m_baseDirectory, "worker-" + Guid.NewGuid().ToString()));

        }
开发者ID:aduggleby,项目名称:dragon,代码行数:31,代码来源:FileFolderMailQueue.cs

示例8: HuobiApi

        internal HuobiApi(IConfiguration config, ILogger logger)
        {
            _config = config;
            _logger = logger;
            var proxyHost = _config.GetValue("proxyHost");
            var proxyPort = _config.GetValue("proxyPort");
            if (null != proxyHost && null != proxyPort)
            {
                _webProxy = new WebProxy(proxyHost, int.Parse(proxyPort));
                _webProxy.Credentials = CredentialCache.DefaultCredentials;
            }

            var nonceOffset = _config.GetValue("nonce_offset");
            if (!String.IsNullOrEmpty(nonceOffset))
                _timeOffset = long.Parse(nonceOffset) / 10000000;
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:16,代码来源:HuobiApi.cs

示例9: NightlyFrogBoiling

 public NightlyFrogBoiling(IConfiguration config, ILogger logger)
 {
     _logger = logger;
     _operativeAmount = double.Parse(config.GetValue("operative_amount"));
     _logger.Message("Nightly Frog Boiling trader initialized with operative amount " + _operativeAmount + " BTC");
     _requestor = new BtcChinaApi(config, logger);
 }
开发者ID:rarach,项目名称:exchange-bots,代码行数:7,代码来源:NightlyFrogBoiling.cs

示例10: CookieSession

        public CookieSession()
        {
            try
            {
                m_configuration = ObjectFactory.GetInstance<IConfiguration>();

                CookieName = m_configuration.GetValue<string>(CONFIG_COOKIENAME, "DRAGON.COOKIE");

                if (HttpContext.Current != null)
                {
                    CheckAndSetHttpContext();
                    SetVariablesFromHttpContext();
                    LoadFromCookie();

                    // WebSocket Requests do not have Response Objects to Save Cookies to
                    if (!HttpContext.Current.IsWebSocketRequest)
                    {
                        SaveToCookie();
                    }
                }
            }
            catch (Exception ex)
            {
                if (Debugger.IsAttached) Debugger.Break();
                throw new Exception("Ctor in CookieSession caught exception.", ex);
            }
        }
开发者ID:aduggleby,项目名称:dragon,代码行数:27,代码来源:CookieSession.cs

示例11: BitstampApi

        public BitstampApi(IConfiguration config, ILogger logger, string baseAssetCode, string counterAssetCode)
        {
            _config = config;
            _logger = logger;

            _hashMaker = new HMACSHA256(Encoding.ASCII.GetBytes(_config.SecretKey));

            _baseAsset = baseAssetCode;
            _counterAsset = counterAssetCode;

            var proxyHost = _config.GetValue("proxyHost");
            var proxyPort = _config.GetValue("proxyPort");
            if (null != proxyHost && null != proxyPort)
            {
                _webProxy = new WebProxy(proxyHost, int.Parse(proxyPort));
                _webProxy.Credentials = CredentialCache.DefaultCredentials;
            }
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:18,代码来源:BitstampApi.cs

示例12: FileFolderTemplateRepository

        public FileFolderTemplateRepository(
            string directory = null,
            IConfiguration configuration = null,
            IFileSystem fileSystem = null,
            string ignorePrefix = "_")
        {
            m_ignorePrefix = ignorePrefix;
            m_fileSystem = fileSystem ?? new DefaultFileSystem();
            m_configuration = configuration ?? new DefaultConfiguration();
            m_baseFolder = (directory ?? string.Empty).Trim();

            if (string.IsNullOrWhiteSpace(m_baseFolder))
            {
                m_baseFolder = m_configuration.GetValue(APP_KEY_FOLDER);
            }

            if (string.IsNullOrWhiteSpace(m_baseFolder))
            {
                throw new ConfigurationMissingException(APP_KEY_FOLDER);
            }

            var culture = m_configuration.GetValue(APP_KEY_DEFLANG);
            if (!string.IsNullOrWhiteSpace(culture))
            {
                try
                {
                    m_cultureInfo = CultureInfo.CreateSpecificCulture(culture);
                }
                catch (CultureNotFoundException)
                {
                    throw new Exception(string.Format("The specified default culture is " +
                                                      "{0} is invalid. Use format such as " +
                                                      "en and en-us.",
                        culture));
                }
            }

            if (!m_fileSystem.ExistDir(m_baseFolder))
            {
                throw new Exception(string.Format("Template directory {0} does not exist.", m_baseFolder));
            }
        }
开发者ID:aduggleby,项目名称:dragon,代码行数:42,代码来源:FileFolderTemplateRepository.cs

示例13: BitfinexApi

        /// <summary>Bitfinex JSON API helper</summary>
        /// <param name="logger">Logger</param>
        /// <param name="minOrderAmount">
        /// Minimum order amount to use when troubleshooting balance inconsistencies
        /// </param>
        public BitfinexApi(IConfiguration config, ILogger logger, double minOrderAmount)
        {
            _config = config;
            _logger = logger;
            var proxyHost = _config.GetValue("proxyHost");
            var proxyPort = _config.GetValue("proxyPort");
            if (null != proxyHost && null != proxyPort)
            {
                _webProxy = new WebProxy(proxyHost, int.Parse(proxyPort));
                _webProxy.Credentials = CredentialCache.DefaultCredentials;
            }

            _minOrderAmount = minOrderAmount;

            var nonceOffset = _config.GetValue("nonce_offset");
            if (!String.IsNullOrEmpty(nonceOffset))
            {
                _nonceOffset = long.Parse(nonceOffset);
            }
        }
开发者ID:rarach,项目名称:exchange-bots,代码行数:25,代码来源:BitfinexApi.cs

示例14: AeEventBasedEmailClient

 public AeEventBasedEmailClient(IConfiguration configuration)
 {
     configuration = configuration.GetSubsection("EmailClient");
     client = new ImapClient(
         configuration.GetValue("Host"),
         configuration.GetValue("Username"),
         configuration.GetValue("Password"),
         ImapClient.AuthMethods.Login,
         configuration.GetValue<int>("Port"),
         configuration.GetValue<bool>("Secure"),
         configuration.GetValue<bool>("SkipSslValidation"));
     client.NewMessage += (sender, args) =>
                              {
                                  if (args.MessageCount > 0)
                                  {
                                      unread.AddRange(client.SearchMessages(SearchCondition.New())
                                                          .Select(message => new MailMessage
                                                                                 {
                                                                                     Date = message.Value.Date,
                                                                                     Sender =
                                                                                         message.Value.Sender,
                                                                                     Receivers = message.Value.To,
                                                                                     Subject =
                                                                                         message.Value.Subject,
                                                                                     Body = message.Value.Body
                                                                                 }));
                                  }
                              };
 }
开发者ID:confa,项目名称:ClientManager,代码行数:29,代码来源:AeEventBasedEmailClient.cs

示例15: AeEmailClient

        public AeEmailClient(IConfiguration configuration)
        {
            configuration = configuration.GetSubsection("EmailClient");
            client = new ImapClient(
                configuration.GetValue("Host"),
                configuration.GetValue("Username"),
                configuration.GetValue("Password"),
                ImapClient.AuthMethods.Login,
                configuration.GetValue<int>("Port"),
                configuration.GetValue<bool>("Secure"),
                configuration.GetValue<bool>("SkipSslValidation"));

            var unreadMessages = client.SearchMessages(SearchCondition.Unseen());
            foreach (var message in unreadMessages)
            {
                client.SetFlags(Flags.Seen, message.Value);
            }

            unread.AddRange(unreadMessages.Select(message => GetInputMailMessage(message.Value)));

            client.NewMessage += (sender, args) =>
                {
                    var message = client.GetMessage(args.MessageCount - 1, false, true);
                    client.SetFlags(Flags.Seen, message);
                    unread.Add(GetInputMailMessage(message));

                    if (null != MailMessageReceived)
                        {
                            MailMessageReceived(this, args);
                        }
                };
        }
开发者ID:titarenko,项目名称:ClientManager,代码行数:32,代码来源:AeEmailClient.cs


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