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


C# IDictionary.GetOrThrow方法代码示例

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


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

示例1: GetSecretInjector

        private static ISecretInjector GetSecretInjector(IDictionary<string, string> arguments)
        {
            ISecretReader secretReader;

            var vaultName = arguments.GetOrDefault<string>(Arguments.VaultName);
            if (string.IsNullOrEmpty(vaultName))
            {
                secretReader = new EmptySecretReader();
            }
            else
            {
                var clientId = arguments.GetOrThrow<string>(Arguments.ClientId);
                var certificateThumbprint = arguments.GetOrThrow<string>(Arguments.CertificateThumbprint);
                var storeName = arguments.GetOrDefault(Arguments.StoreName, StoreName.My);
                var storeLocation = arguments.GetOrDefault(Arguments.StoreLocation, StoreLocation.LocalMachine);
                var shouldValidateCert = arguments.GetOrDefault(Arguments.ValidateCertificate, false);

                var keyVaultConfig = new KeyVaultConfiguration(vaultName, clientId, certificateThumbprint, storeName, storeLocation, shouldValidateCert);

                secretReader = new CachingSecretReader(new KeyVaultReader(keyVaultConfig),
                    arguments.GetOrDefault(Arguments.RefreshIntervalSec, CachingSecretReader.DefaultRefreshIntervalSec));
            }

            return new SecretInjector(secretReader);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:25,代码来源:CommandHelpers.cs

示例2: Init

 protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
 {
     _gallery = arguments.GetOrThrow<string>(Arguments.Gallery);
     _verbose = arguments.GetOrDefault(Arguments.Verbose, false);
     _id = arguments.GetOrThrow<string>(Arguments.Id);
     _version = arguments.GetOrDefault<string>(Arguments.Version);
     _storageFactory = CommandHelpers.CreateStorageFactory(arguments, _verbose);
 }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:8,代码来源:Package2CatalogJob.cs

示例3: Init

        protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
        {
            _directory = CommandHelpers.GetLuceneDirectory(arguments);
            _source = arguments.GetOrThrow<string>(Arguments.Source);
            _verbose = arguments.GetOrDefault(Arguments.Verbose, false);

            _registration = arguments.GetOrDefault<string>(Arguments.Registration);
            if (_registration == null)
            {
                Logger.LogInformation("Lucene index will be created up to the end of the catalog (alternatively if you provide a registration it will not pass that)");
            }

            _catalogBaseAddress = arguments.GetOrDefault<string>(Arguments.CatalogBaseAddress);
            if (_catalogBaseAddress == null)
            {
                Logger.LogInformation("No catalogBaseAddress was specified so the Lucene index will NOT contain the storage paths");
            }

            _storageBaseAddress = arguments.GetOrDefault<string>(Arguments.StorageBaseAddress);

            Logger.LogInformation("CONFIG source: \"{ConfigSource}\" registration: \"{Registration}\"" +
                                   " catalogBaseAddress: \"{CatalogBaseAddress}\" storageBaseAddress: \"{StorageBaseAddress}\"",
                                   _source,
                                   _registration ?? "(null)",
                                   _catalogBaseAddress ?? "(null)",
                                   _storageBaseAddress ?? "(null)");

            _handlerFunc = CommandHelpers.GetHttpMessageHandlerFactory(_verbose, _catalogBaseAddress, _storageBaseAddress);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:29,代码来源:Catalog2LuceneJob.cs

示例4: Init

        protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
        {
            var source = arguments.GetOrThrow<string>(Arguments.Source);
            var unlistShouldDelete = arguments.GetOrDefault(Arguments.UnlistShouldDelete, false);
            var verbose = arguments.GetOrDefault(Arguments.Verbose, false);

            var contentBaseAddress = arguments.GetOrDefault<string>(Arguments.ContentBaseAddress);

            StorageFactory storageFactoryToUse;

            var storageFactory = CommandHelpers.CreateStorageFactory(arguments, verbose);
            var compressedStorageFactory = CommandHelpers.CreateCompressedStorageFactory(arguments, verbose);

            Logger.LogInformation("CONFIG source: \"{ConfigSource}\" storage: \"{Storage}\"", source, storageFactory);

            RegistrationMakerCatalogItem.PackagePathProvider = new PackagesFolderPackagePathProvider();

            if (compressedStorageFactory != null)
            {
                var secondaryStorageBaseUrlRewriter = new SecondaryStorageBaseUrlRewriter(new List<KeyValuePair<string, string>>
                {
                    // always rewrite storage root url in seconary
                    new KeyValuePair<string, string>(storageFactory.BaseAddress.ToString(), compressedStorageFactory.BaseAddress.ToString())
                });

                var aggregateStorageFactory = new AggregateStorageFactory(
                    storageFactory,
                    new[] { compressedStorageFactory },
                    secondaryStorageBaseUrlRewriter.Rewrite);

                storageFactoryToUse = aggregateStorageFactory;
            }
            else
            {
                storageFactoryToUse = storageFactory;
            }

            _collector = new RegistrationCollector(new Uri(source), storageFactoryToUse, CommandHelpers.GetHttpMessageHandlerFactory(verbose))
            {
                ContentBaseAddress = contentBaseAddress == null
                    ? null
                    : new Uri(contentBaseAddress)
            };

            var storage = storageFactoryToUse.Create();
            _front = new DurableCursor(storage.ResolveUri("cursor.json"), storage, MemoryCursor.MinValue);
            _back = MemoryCursor.CreateMax();
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:48,代码来源:Catalog2RegistrationJob.cs

示例5: Init

        protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
        {
            Gallery = arguments.GetOrThrow<string>(Arguments.Gallery);
            Verbose = arguments.GetOrDefault(Arguments.Verbose, false);
            StartDate = arguments.GetOrDefault(Arguments.StartDate, DateTimeMinValueUtc);

            var catalogStorageFactory = CommandHelpers.CreateStorageFactory(arguments, Verbose);
            var auditingStorageFactory = CommandHelpers.CreateSuffixedStorageFactory("Auditing", arguments, Verbose);

            Logger.LogInformation("CONFIG source: \"{ConfigSource}\" storage: \"{Storage}\"", Gallery, catalogStorageFactory);

            CatalogStorage = catalogStorageFactory.Create();
            AuditingStorage = auditingStorageFactory.Create();

            Top = 20;
            Timeout = TimeSpan.FromSeconds(300);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:17,代码来源:Feed2CatalogJob.cs

示例6: Init

        protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
        {
            var source = arguments.GetOrThrow<string>(Arguments.Source);
            var verbose = arguments.GetOrDefault(Arguments.Verbose, false);
            var contentBaseAddress = arguments.GetOrDefault<string>(Arguments.ContentBaseAddress);
            var storageFactory = CommandHelpers.CreateStorageFactory(arguments, verbose);

            Logger.LogInformation("CONFIG source: \"{ConfigSource}\" storage: \"{Storage}\"", source, storageFactory);

            _collector = new DnxCatalogCollector(new Uri(source), storageFactory, CommandHelpers.GetHttpMessageHandlerFactory(verbose))
            {
                ContentBaseAddress = contentBaseAddress == null ? null : new Uri(contentBaseAddress)
            };

            var storage = storageFactory.Create();
            _front = new DurableCursor(storage.ResolveUri("cursor.json"), storage, MemoryCursor.MinValue);
            _back = MemoryCursor.CreateMax();
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:18,代码来源:Catalog2DnxJob.cs

示例7: Init

 protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
 {
     _connectionString = arguments.GetOrThrow<string>(Arguments.ConnectionString);
     _path = arguments.GetOrThrow<string>(Arguments.Path);
 }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:5,代码来源:Db2LuceneJob.cs

示例8: GetLuceneDirectoryImpl

        public static Lucene.Net.Store.Directory GetLuceneDirectoryImpl(IDictionary<string, string> arguments, IDictionary<string, string> argumentNameMap, bool required = true)
        {
            try
            {
                var luceneDirectoryType = arguments.GetOrThrow<string>(argumentNameMap[Arguments.DirectoryType]);

                if (luceneDirectoryType.Equals(Arguments.FileStorageType, StringComparison.InvariantCultureIgnoreCase))
                {
                    var lucenePath = arguments.GetOrThrow<string>(argumentNameMap[Arguments.Path]);

                    var directoryInfo = new DirectoryInfo(lucenePath);

                    if (directoryInfo.Exists)
                    {
                        return new SimpleFSDirectory(directoryInfo);
                    }

                    directoryInfo.Create();
                    directoryInfo.Refresh();

                    return new SimpleFSDirectory(directoryInfo);
                }
                if (luceneDirectoryType.Equals(Arguments.AzureStorageType, StringComparison.InvariantCultureIgnoreCase))
                {
                    var luceneStorageAccountName = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StorageAccountName]);

                    var luceneStorageKeyValue = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StorageKeyValue]);

                    var luceneStorageContainer = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StorageContainer]);

                    var credentials = new StorageCredentials(luceneStorageAccountName, luceneStorageKeyValue);
                    var account = new CloudStorageAccount(credentials, true);
                    return new AzureDirectory(account, luceneStorageContainer);
                }
                Trace.TraceError("Unrecognized Lucene Directory Type \"{0}\"", luceneDirectoryType);
                return null;
            }
            catch (ArgumentException)
            {
                if (required)
                {
                    throw;
                }

                return null;
            }
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:47,代码来源:CommandHelpers.cs

示例9: CreateStorageFactoryImpl

        private static StorageFactory CreateStorageFactoryImpl(IDictionary<string, string> arguments, IDictionary<string, string> argumentNameMap, bool verbose)
        {
            Uri storageBaseAddress = null;
            var storageBaseAddressStr = arguments.GetOrDefault<string>(argumentNameMap[Arguments.StorageBaseAddress]);
            if (!string.IsNullOrEmpty(storageBaseAddressStr))
            {
                storageBaseAddressStr = storageBaseAddressStr.TrimEnd('/') + "/";

                storageBaseAddress = new Uri(storageBaseAddressStr);
            }

            var storageType = arguments.GetOrThrow<string>(Arguments.StorageType);

            if (storageType.Equals(Arguments.FileStorageType, StringComparison.InvariantCultureIgnoreCase))
            {
                var storagePath = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StoragePath]);

                if (storageBaseAddress != null)
                {
                    return new FileStorageFactory(storageBaseAddress, storagePath) {Verbose = verbose};
                }

                TraceRequiredArgument(argumentNameMap[Arguments.StorageBaseAddress]);
                return null;
            }

            if (Arguments.AzureStorageType.Equals(storageType, StringComparison.InvariantCultureIgnoreCase))
            {
                var storageAccountName = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StorageAccountName]);
                var storageKeyValue = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StorageKeyValue]);
                var storageContainer = arguments.GetOrThrow<string>(argumentNameMap[Arguments.StorageContainer]);
                var storagePath = arguments.GetOrDefault<string>(argumentNameMap[Arguments.StoragePath]);

                var credentials = new StorageCredentials(storageAccountName, storageKeyValue);
                var account = new CloudStorageAccount(credentials, true);
                return new AzureStorageFactory(account, storageContainer, storagePath, storageBaseAddress) { Verbose = verbose };
            }
            
            throw new ArgumentException($"Unrecognized storageType \"{storageType}\"");
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:40,代码来源:CommandHelpers.cs

示例10: InitStrike

 private void InitStrike(IDictionary<string, string> arguments)
 {
     _indexFile = arguments.GetOrThrow<string>(Arguments.IndexFile);
     _cursorFile = arguments.GetOrThrow<string>(Arguments.CursorFile);
 }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:5,代码来源:LightningJob.cs

示例11: InitPrepare

 private void InitPrepare(IDictionary<string, string> arguments)
 {
     _outputFolder = arguments.GetOrThrow<string>(Arguments.OutputFolder);
     _catalogIndex = arguments.GetOrThrow<string>(Arguments.CatalogIndex);
     _templateFile = arguments.GetOrThrow<string>(Arguments.TemplateFile);
     _batchSize = arguments.GetOrThrow<string>(Arguments.BatchSize);
 }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:LightningJob.cs

示例12: Init

        protected override void Init(IDictionary<string, string> arguments, CancellationToken cancellationToken)
        {
            PrintLightning();

            _command = arguments.GetOrThrow<string>(Arguments.Command);
            _verbose = arguments.GetOrDefault(Arguments.Verbose, false);

            _log = _verbose ? Console.Out : new StringWriter();

            switch (_command.ToLowerInvariant())
            {
                case "charge":
                case "prepare":
                    InitPrepare(arguments);
                    break;
                case "strike":
                    InitStrike(arguments);
                    break;
                default:
                    throw new ArgumentNullException();
            }

            _contentBaseAddress = arguments.GetOrThrow<string>(Arguments.ContentBaseAddress);
            _storageAccount = arguments.GetOrThrow<string>(Arguments.StorageAccount);
            _storageContainer = arguments.GetOrThrow<string>(Arguments.StorageContainer);
            _storageBaseAddress = arguments.GetOrThrow<string>(Arguments.StorageBaseAddress);
            _compress = arguments.GetOrDefault(Arguments.Compress, false);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:28,代码来源:LightningJob.cs


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