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


C# IConfigurationProvider.GetValue方法代码示例

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


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

示例1: CreateConnectionData

        private void CreateConnectionData(IConfigurationProvider configurationProvider)
        {
            string serviceBusConnectionString = configurationProvider.GetValue("serviceBusConnectionString");
            if (string.IsNullOrWhiteSpace(serviceBusConnectionString))
            {
                throw new ConfigurationErrorsException(
                    "Configuration parameter 'serviceBusConnectionString' must be set to a valid Service Bus connection string");
            }

            string eventHubName = configurationProvider.GetValue("eventHubName");
            if (string.IsNullOrWhiteSpace(eventHubName))
            {
                throw new ConfigurationErrorsException("Configuration parameter 'eventHubName' must not be empty");
            }

            this.connectionData = new EventHubConnectionData();
            this.connectionData.EventHubName = eventHubName;

            ServiceBusConnectionStringBuilder connStringBuilder = new ServiceBusConnectionStringBuilder(serviceBusConnectionString);
            connStringBuilder.TransportType = TransportType.Amqp;
            this.connectionData.MessagingFactories = new MessagingFactory[ConcurrentConnections];
            for (uint i = 0; i < ConcurrentConnections; i++)
            {
                this.connectionData.MessagingFactories[i] = MessagingFactory.CreateFromConnectionString(connStringBuilder.ToString());
            }
        }
开发者ID:TylerAngell,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:26,代码来源:EventHubListener.cs

示例2: CreateTableClient

        private void CreateTableClient(IConfigurationProvider configurationProvider)
        {
            string accountConnectionString = configurationProvider.GetValue("StorageAccountConnectionString");
            string sasToken = configurationProvider.GetValue("StorageAccountSasToken");

            if (string.IsNullOrWhiteSpace(sasToken) && string.IsNullOrWhiteSpace(accountConnectionString))
            {
                throw new ConfigurationErrorsException(
                    "Configuration must specify either the storage account connection string ('StorageAccountConnectionString' parameter) or SAS token ('StorageAccountSasToken' paramteter)");
            }

            string storageTableName = configurationProvider.GetValue("StorageTableName");
            if (string.IsNullOrWhiteSpace(storageTableName))
            {
                throw new ConfigurationErrorsException("Configuration must specify the target storage name ('storageTableName' parameter)");
            }

            CloudStorageAccount storageAccount = string.IsNullOrWhiteSpace(sasToken)
                ? CloudStorageAccount.Parse(accountConnectionString)
                : new CloudStorageAccount(new StorageCredentials(sasToken), useHttps: true);
            this.cloudTable = storageAccount.CreateCloudTableClient().GetTableReference(storageTableName);

            try
            {
                this.cloudTable.CreateIfNotExists();
            }
            catch (Exception e)
            {
                this.ReportListenerProblem("Could not ensure that destination Azure storage table exists" + Environment.NewLine + e.ToString());
                throw;
            }
        }
开发者ID:TylerAngell,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:32,代码来源:TableStorageEventListener.cs

示例3: CreateDocumentStore

        private IDocumentStore CreateDocumentStore(IApplicationHost applicationHost,IConfigurationProvider configurationProvider)
        {
            var useRemoteDatabase = configurationProvider.GetValue("Database/UseRemote", false);

            if ( useRemoteDatabase )
            {
                return new DocumentStore() {ConnectionStringName = "Default"};
            }
            else
            {
                var dataPath = applicationHost.MapPath(configurationProvider.GetValue("Database/LocalPath", "~/App_Data"));
                if ( !Directory.Exists(dataPath))
                {
                    Directory.CreateDirectory(dataPath);
                }

                return new EmbeddableDocumentStore() { DataDirectory = dataPath};
            }
        }
开发者ID:BernhardGlueck,项目名称:Wmc,代码行数:19,代码来源:RavenDbModule.cs

示例4: CreateElasticClient

        private ElasticClient CreateElasticClient(IConfigurationProvider configurationProvider)
        {
            string esServiceUriString = configurationProvider.GetValue("serviceUri");
            Uri esServiceUri;
            bool serviceUriIsValid = Uri.TryCreate(esServiceUriString, UriKind.Absolute, out esServiceUri);
            if (!serviceUriIsValid)
            {
                throw new ConfigurationErrorsException("serviceUri must be a valid, absolute URI");
            }

            string userName = configurationProvider.GetValue("userName");
            string password = configurationProvider.GetValue("password");
            if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password))
            {
                throw new ConfigurationErrorsException("Invalid Elastic Search credentials");
            }

            ConnectionSettings config = new ConnectionSettings(esServiceUri).BasicAuthentication(userName, password);
            return new ElasticClient(config);
        }
开发者ID:Azure-Samples,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:20,代码来源:ElasticSearchListener.cs

示例5: ApplicationInsightsEventListener

        public ApplicationInsightsEventListener(IConfigurationProvider configurationProvider, IHealthReporter healthReporter) : base(configurationProvider, healthReporter)
        {
            if (this.Disabled)
            {
                return;
            }

            Debug.Assert(configurationProvider != null);

            telemetry = new TelemetryClient();
            telemetry.Context.InstrumentationKey = configurationProvider.GetValue(AppInsightsKeyName);

            this.Sender = new ConcurrentEventSender<EventData>(
                eventBufferSize: 1000,
                maxConcurrency: 2,
                batchSize: 100,
                noEventsDelay: TimeSpan.FromMilliseconds(1000),
                transmitterProc: this.SendEventsAsync,
                healthReporter: healthReporter);
        }
开发者ID:enemaerke,项目名称:service-fabric-dotnet-management-party-cluster,代码行数:20,代码来源:ApplicationInsightsEventListener.cs


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