aboutsummaryrefslogtreecommitdiff
path: root/src/wix/WixToolset.Core.ExtensionCache/WixToolsetCoreServiceProviderExtensions.cs
blob: 424fc4699462832e9f180ac0977355c1925344f2 (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
29
30
31
32
33
34
35
36
// 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;

    /// <summary>
    /// Extensions methods for adding ExtensionCache services.
    /// </summary>
    public static class WixToolsetCoreServiceProviderExtensions
    {
        /// <summary>
        /// Adds ExtensionCache services.
        /// </summary>
        /// <param name="coreProvider"></param>
        /// <returns></returns>
        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;
        }
    }
}