// 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 System.Collections.Generic;
using System.Linq;
using WixToolset.Data;
using WixToolset.Data.Symbols;
using WixToolset.Data.WindowsInstaller;
using WixToolset.Extensibility.Data;
using WixToolset.Extensibility.Services;
///
/// Base class for creating a preprocessor extension.
///
public abstract class BaseWindowsInstallerBackendBinderExtension : IWindowsInstallerBackendBinderExtension
{
///
/// Context for use by the extension.
///
protected IBindContext Context { get; private set; }
///
/// Messaging for use by the extension.
///
protected IMessaging Messaging { get; private set; }
///
/// Backend helper for use by the extension.
///
protected IWindowsInstallerBackendHelper BackendHelper { get; private set; }
///
/// Optional table definitions.
///
public virtual IEnumerable TableDefinitions => Enumerable.Empty();
///
/// Creates a resolved cabinet result.
///
protected IResolvedCabinet CreateResolvedCabinet() => this.Context.ServiceProvider.GetService();
///
/// See
///
public virtual void PreBackendBind(IBindContext context)
{
this.Context = context;
this.Messaging = context.ServiceProvider.GetService();
this.BackendHelper = context.ServiceProvider.GetService();
}
///
/// See
///
public virtual void SymbolsFinalized(IntermediateSection section)
{
}
///
/// See
///
public virtual IResolvedCabinet ResolveCabinet(string cabinetPath, IEnumerable files) => null;
///
/// See
///
public virtual string ResolveMedia(MediaSymbol mediaRow, string mediaLayoutDirectory, string layoutDirectory) => null;
///
/// See
///
public virtual bool TryProcessSymbol(IntermediateSection section, IntermediateSymbol symbol, WindowsInstallerData data, TableDefinitionCollection tableDefinitions)
{
if (this.TableDefinitions.Any(t => t.SymbolDefinition == symbol.Definition))
{
return this.BackendHelper.TryAddSymbolToMatchingTableDefinitions(section, symbol, data, tableDefinitions);
}
return false;
}
///
/// See
///
public virtual void PostBackendBind(IBindResult result)
{
}
}
}