aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Extensibility/BaseBinderExtension.cs
blob: 3869d1ed0fd172702b9b188944f5f1cb93c69828 (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
37
38
39
40
41
42
43
44
45
46
47
// 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.Extensibility
{
    using WixToolset.Extensibility.Data;
    using WixToolset.Extensibility.Services;

    /// <summary>
    /// Base class for creating a resolver extension.
    /// </summary>
    public abstract class BaseBinderExtension : IBinderExtension
    {
        /// <summary>
        /// Context for use by the extension.
        /// </summary>
        protected IBindContext Context { get; private set; }

        /// <summary>
        /// Messaging for use by the extension.
        /// </summary>
        protected IMessaging Messaging { get; private set; }

        /// <summary>
        /// BackendHelper for use by the extension.
        /// </summary>
        protected IBackendHelper BackendHelper { get; private set; }

        /// <summary>
        /// Called at the beginning of bind.
        /// </summary>
        public virtual void PreBind(IBindContext context)
        {
            this.Context = context;

            this.Messaging = context.ServiceProvider.GetService<IMessaging>();

            this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>();
        }

        /// <summary>
        /// Called at the end of bind.
        /// </summary>
        public virtual void PostBind(IBindResult result)
        {
        }
    }
}