src/NuGetGallery/App_Start/StorageDependent.cs
/// <summary>
/// Group the storage dependents by Azure Storage connection string then generate a binding key so that
/// <see cref="IFileStorageService"/> instances are shared.
/// </summary>
Group the storage dependents by Azure Storage connection string then generate a binding key so that
instances are shared.
Group the storage dependents by Azure Storage connection string then generate a binding key so that instances are shared .
public static IEnumerable<StorageDependent> GetAll(IAppConfiguration configuration)
        {
            const string DefaultBindingKey = "Default";
            var dependents = new[]
            {
                Create<CertificateService, ICertificateService>(configuration.AzureStorage_UserCertificates_ConnectionString, isSingleInstance: false),
                Create<ContentService, IContentService>(configuration.AzureStorage_Content_ConnectionString, isSingleInstance: true),
                Create<PackageFileService, IPackageFileService>(configuration.AzureStorage_Packages_ConnectionString, isSingleInstance: false),
                Create<SymbolPackageFileService, ISymbolPackageFileService>(configuration.AzureStorage_Packages_ConnectionString, isSingleInstance: false),
                Create<UploadFileService, IUploadFileService>(configuration.AzureStorage_Uploads_ConnectionString, isSingleInstance: false),
                Create<CoreLicenseFileService, ICoreLicenseFileService>(configuration.AzureStorage_FlatContainer_ConnectionString, isSingleInstance: false),
                Create<CoreReadmeFileService, ICoreReadmeFileService>(configuration.AzureStorage_FlatContainer_ConnectionString, isSingleInstance: false),
                Create<RevalidationStateService, IRevalidationStateService>(configuration.AzureStorage_Revalidation_ConnectionString, isSingleInstance: false),
                Create<EditableFeatureFlagFileStorageService, IFeatureFlagStorageService>(configuration.AzureStorage_Content_ConnectionString, isSingleInstance: true)
            };
            var connectionStringToBindingKey = dependents
                .GroupBy(d => d.AzureStorageConnectionString ?? DefaultBindingKey)
                .ToDictionary(g => g.Key, g => string.Join(" ", g.Select(d => d.BindingKey)));
            foreach (var dependent in dependents)
            {
                var bindingKey = connectionStringToBindingKey[dependent.AzureStorageConnectionString ?? DefaultBindingKey];
                yield return dependent.SetBindingKey(bindingKey);
            }
        }
public static IEnumerable < StorageDependent > GetAll ( IAppConfiguration configuration ) { const string DefaultBindingKey = " " ; var dependents = new [ ] { Create < CertificateService , ICertificateService > ( configuration . AzureStorage_UserCertificates_ConnectionString , isSingleInstance : false ) , Create < ContentService , IContentService > ( configuration . AzureStorage_Content_ConnectionString , isSingleInstance : true ) , Create < PackageFileService , IPackageFileService > ( configuration . AzureStorage_Packages_ConnectionString , isSingleInstance : false ) , Create < SymbolPackageFileService , ISymbolPackageFileService > ( configuration . AzureStorage_Packages_ConnectionString , isSingleInstance : false ) , Create < UploadFileService , IUploadFileService > ( configuration . AzureStorage_Uploads_ConnectionString , isSingleInstance : false ) , Create < CoreLicenseFileService , ICoreLicenseFileService > ( configuration . AzureStorage_FlatContainer_ConnectionString , isSingleInstance : false ) , Create < CoreReadmeFileService , ICoreReadmeFileService > ( configuration . AzureStorage_FlatContainer_ConnectionString , isSingleInstance : false ) , Create < RevalidationStateService , IRevalidationStateService > ( configuration . AzureStorage_Revalidation_ConnectionString , isSingleInstance : false ) , Create < EditableFeatureFlagFileStorageService , IFeatureFlagStorageService > ( configuration . AzureStorage_Content_ConnectionString , isSingleInstance : true ) } ; var connectionStringToBindingKey = dependents . GroupBy ( d => d . AzureStorageConnectionString ?? DefaultBindingKey ) . ToDictionary ( g => g . Key , g => string . Join ( " " , g . Select ( d => d . BindingKey ) ) ) ; foreach ( var dependent in dependents ) { var bindingKey = connectionStringToBindingKey [ dependent . AzureStorageConnectionString ?? DefaultBindingKey ] ; yield return dependent . SetBindingKey ( bindingKey ) ; } }
Group the storage dependents by Azure Storage connection string then generate a binding key so that
instances are shared.
Group the storage dependents by Azure Storage connection string then generate a binding key so that instances are shared .
/// This array must be added to as we implement more services that use <see cref="IFileStorageService"/>.
configuration
IAppConfiguration