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


C# IConfiguration.HasValueFor方法代码示例

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


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

示例1: FileWatcherBasedPackageUploader

        /// <summary>
        /// Initializes a new instance of the <see cref="FileWatcherBasedPackageUploader"/> class.
        /// </summary>
        /// <param name="packageQueue">The object that queues packages that need to be processed.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="diagnostics">The object providing the diagnostics methods for the application.</param>
        internal FileWatcherBasedPackageUploader(
            IQueueSymbolPackages packageQueue,
            IConfiguration configuration,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => packageQueue);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => diagnostics);

                Lokad.Enforce.With<ArgumentException>(
                    configuration.HasValueFor(CoreConfigurationKeys.s_UploadPath),
                    Resources.Exceptions_Messages_MissingConfigurationValue_WithKey,
                    CoreConfigurationKeys.s_UploadPath);
            }

            m_Queue = packageQueue;
            m_Diagnostics = diagnostics;

            var uploadPath = configuration.Value<string>(CoreConfigurationKeys.s_UploadPath);
            m_Watcher = new FileSystemWatcher
            {
                Path = uploadPath,
                Filter = "*.symbols.nupkg",
                EnableRaisingEvents = false,
                NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime,
            };

            m_Watcher.Created += HandleFileCreated;
        }
开发者ID:pvandervelde,项目名称:nAnicitus,代码行数:36,代码来源:FileWatcherBasedPackageUploader.cs

示例2: TestCycle

        /// <summary>
        /// Initializes a new instance of the <see cref="TestCycle"/> class.
        /// </summary>
        /// <param name="configuration">The object that provides access to the configuration options for the application.</param>
        /// <param name="testController">The object that handles test execution.</param>
        /// <param name="executingTests">The object that stores information about the test that are currently being executed.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="configuration"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="testController"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="executingTests"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="diagnostics"/> is <see langword="null" />.
        /// </exception>
        public TestCycle(
            IConfiguration configuration,
            IControlTests testController,
            IStoreActiveTests executingTests,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => testController);
                Lokad.Enforce.Argument(() => executingTests);
                Lokad.Enforce.Argument(() => diagnostics);
            }

            m_TestController = testController;
            m_Diagnostics = diagnostics;

            m_ExecutingTests = executingTests;

            m_CycleTimeInMilliSeconds = configuration.HasValueFor(MasterServiceConfigurationKeys.KeepAliveCycleTimeInMilliSeconds)
                ? configuration.Value<int>(MasterServiceConfigurationKeys.KeepAliveCycleTimeInMilliSeconds)
                : GlobalConstants.DefaultKeepAliveCycleTimeInMilliseconds;
            m_MaximumNumberOfCycleFailures = configuration.HasValueFor(MasterServiceConfigurationKeys.MaximumNumberOfCycleFailures)
                ? configuration.Value<int>(MasterServiceConfigurationKeys.MaximumNumberOfCycleFailures)
                : GlobalConstants.DefaultMaximumNumberOfCycleFailures;

            m_Timer.AutoReset = true;
            m_Timer.Interval = m_CycleTimeInMilliSeconds;
            m_Timer.Elapsed += TimerElapsed;
        }
开发者ID:pvandervelde,项目名称:Sherlock,代码行数:48,代码来源:TestCycle.cs

示例3: DetermineUsableEndpoints

        private static IEnumerable<Tuple<EndpointId, IDatasetActivationCommands>> DetermineUsableEndpoints(
            IEnumerable<Tuple<EndpointId, IDatasetActivationCommands>> availableEndpoints,
            IConfiguration configuration)
        {
            IEnumerable<Tuple<EndpointId, IDatasetActivationCommands>> usableNodes = availableEndpoints;

            var key = ActivationConfigurationKeys.OffLimitsEndpoints;
            if (configuration.HasValueFor(key))
            {
                var offlimitEndpoints = configuration.Value<IDictionary<string, object>>(key);
                var nonUsableNodes = from node in availableEndpoints
                                     from string machine in offlimitEndpoints.Values
                                     where node.Item1.IsOnMachine(machine)
                                     select node.Item1;

                usableNodes = from node in availableEndpoints
                              where (!nonUsableNodes.Contains(node.Item1))
                              select node;
            }

            return usableNodes;
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:22,代码来源:RemoteDatasetDistributor.cs

示例4: SymbolIndexer

        /// <summary>
        /// Initializes a new instance of the <see cref="SymbolIndexer"/> class.
        /// </summary>
        /// <param name="packageQueue">The object that queues packages that need to be processed.</param>
        /// <param name="configuration">The configuration.</param>
        /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param>
        public SymbolIndexer(
            IQueueSymbolPackages packageQueue,
            IConfiguration configuration,
            SystemDiagnostics diagnostics)
        {
            {
                Lokad.Enforce.Argument(() => packageQueue);
                Lokad.Enforce.Argument(() => configuration);
                Lokad.Enforce.Argument(() => diagnostics);

                Lokad.Enforce.With<ArgumentException>(
                    configuration.HasValueFor(CoreConfigurationKeys.s_SourceIndexUncPath),
                    Resources.Exceptions_Messages_MissingConfigurationValue_WithKey,
                    CoreConfigurationKeys.s_SourceIndexUncPath);
                Lokad.Enforce.With<ArgumentException>(
                    configuration.HasValueFor(CoreConfigurationKeys.s_SymbolsIndexUncPath),
                    Resources.Exceptions_Messages_MissingConfigurationValue_WithKey,
                    CoreConfigurationKeys.s_SymbolsIndexUncPath);
                Lokad.Enforce.With<ArgumentException>(
                    configuration.HasValueFor(CoreConfigurationKeys.s_ProcessedPackagesPath),
                    Resources.Exceptions_Messages_MissingConfigurationValue_WithKey,
                    CoreConfigurationKeys.s_ProcessedPackagesPath);
            }

            m_Diagnostics = diagnostics;
            m_Queue = packageQueue;
            m_Queue.OnEnqueue += HandleOnEnqueue;

            var debuggingToolsDirectory = configuration.HasValueFor(CoreConfigurationKeys.s_DebuggingToolsDirectory)
                ? configuration.Value<string>(CoreConfigurationKeys.s_DebuggingToolsDirectory)
                : DefaultSymbolServerToolsDirectory();
            m_SymStorePath = Path.Combine(debuggingToolsDirectory, "symstore.exe");
            m_SrcToolPath = Path.Combine(debuggingToolsDirectory, "srcsrv", "srctool.exe");
            m_PdbStrPath = Path.Combine(debuggingToolsDirectory, "srcsrv", "pdbstr.exe");
            m_SourceUncPath = configuration.Value<string>(CoreConfigurationKeys.s_SourceIndexUncPath);
            m_SymbolsUncPath = configuration.Value<string>(CoreConfigurationKeys.s_SymbolsIndexUncPath);
            m_ProcessedPackagesPath = configuration.Value<string>(CoreConfigurationKeys.s_ProcessedPackagesPath);
        }
开发者ID:pvandervelde,项目名称:nAnicitus,代码行数:44,代码来源:SymbolIndexer.cs


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