// 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.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; /// /// Base class for creating a compiler extension. /// public abstract class BaseCompilerExtension : ICompilerExtension { /// /// Context for use by the extension. /// protected ICompileContext Context { get; private set; } /// /// Messaging for use by the extension. /// protected IMessaging Messaging { get; private set; } /// /// ParserHelper for use by the extension. /// protected IParseHelper ParseHelper { get; private set; } /// /// Gets the schema namespace for this extension. /// /// Schema namespace supported by this extension. public abstract XNamespace Namespace { get; } /// /// Creates a component key path. /// protected IComponentKeyPath CreateComponentKeyPath() => this.Context.ServiceProvider.GetService(); /// /// Called at the beginning of the compilation of a source file. /// public virtual void PreCompile(ICompileContext context) { this.Context = context; this.Messaging = context.ServiceProvider.GetService(); this.ParseHelper = context.ServiceProvider.GetService(); } /// /// See /// public virtual void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary context) { this.ParseHelper.UnexpectedAttribute(parentElement, attribute); } /// /// See /// public virtual void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { this.ParseHelper.UnexpectedElement(parentElement, element); } /// /// See /// public virtual IComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { this.ParseElement(intermediate, section, parentElement, element, context); return null; } /// /// Called at the end of the compilation of a source file. /// public virtual void PostCompile(Intermediate intermediate) { } } }