aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.ExtensionCache/WixToolsetCoreServiceProviderExtensions.cs
blob: 535a08f72e4476fc6cc28c6a105df227a4b96337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

namespace WixToolset.Core.ExtensionCache
{
    using System;
    using System.Collections.Generic;
    using WixToolset.Extensibility.Services;

    public static class WixToolsetCoreServiceProviderExtensions
    {
        public static IWixToolsetCoreServiceProvider AddExtensionCacheManager(this IWixToolsetCoreServiceProvider coreProvider)
        {
            var extensionManager = coreProvider.GetService<IExtensionManager>();
            extensionManager.Add(typeof(ExtensionCacheManagerExtensionFactory).Assembly);

            coreProvider.AddService(CreateExtensionCacheManager);
            return coreProvider;
        }

        private static ExtensionCacheManager CreateExtensionCacheManager(IWixToolsetCoreServiceProvider coreProvider, Dictionary<Type, object> singletons)
        {
            var extensionCacheManager = new ExtensionCacheManager();
            singletons.Add(typeof(ExtensionCacheManager), extensionCacheManager);

            return extensionCacheManager;
        }
    }
}