// 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.Burn;
using WixToolset.Extensibility.Data;
using WixToolset.Extensibility.Services;
///
/// Base class for creating a Burn backend extension.
///
public abstract class BaseBurnBackendExtension : IBurnBackendExtension
{
///
/// 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 IBurnBackendHelper BackendHelper { get; private set; }
///
/// Optional symbol definitions.
///
protected virtual IEnumerable SymbolDefinitions => Enumerable.Empty();
///
/// Called after all output changes occur and right before the output is bound into its final format.
///
public virtual void BundleFinalize()
{
}
///
/// Called after output is bound into its final format.
///
///
public virtual void PostBackendBind(IBindResult result)
{
}
///
/// Called before binding occurs.
///
///
public virtual void PreBackendBind(IBindContext context)
{
this.Context = context;
this.Messaging = context.ServiceProvider.GetService();
this.BackendHelper = context.ServiceProvider.GetService();
}
///
///
///
///
///
///
///
///
///
public virtual IResolveFileResult ResolveRelatedFile(string source, string relatedSource, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage)
{
return null;
}
///
///
///
///
///
///
///
///
///
public virtual string ResolveUrl(string url, string fallbackUrl, string packageId, string payloadId, string fileName)
{
return null;
}
///
/// Called for each extension symbol that hasn't been handled yet.
/// Use IBurnBackendHelper to add data to the appropriate data manifest.
///
/// The linked section.
/// The current symbol.
///
/// True if the extension handled the symbol, false otherwise.
/// The Burn backend will warn on all unhandled symbols.
///
public virtual bool TryAddSymbolToDataManifest(IntermediateSection section, IntermediateSymbol symbol)
{
if (this.SymbolDefinitions.Any(t => t == symbol.Definition) &&
symbol.Definition.HasTag(BurnConstants.BootstrapperApplicationDataSymbolDefinitionTag))
{
this.BackendHelper.AddBootstrapperApplicationData(symbol);
return true;
}
return false;
}
}
}