// 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;
///
/// Base class for creating a compiler extension.
///
public abstract class CompilerExtension : ICompilerExtension
{
///
/// Gets or sets the compiler core for the extension.
///
/// Compiler core for the extension.
public ICompilerCore Core { get; set; }
///
/// Gets the schema namespace for this extension.
///
/// Schema namespace supported by this extension.
public XNamespace Namespace { get; protected set; }
///
/// Called at the beginning of the compilation of a source file.
///
public virtual void Initialize()
{
}
///
/// Processes an attribute for the Compiler.
///
/// Parent element of attribute.
/// Attribute to process.
/// Extra information about the context in which this element is being parsed.
public virtual void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary context)
{
this.Core.UnexpectedAttribute(parentElement, attribute);
}
///
/// Processes an element for the Compiler.
///
/// Parent element of element to process.
/// Element to process.
/// Extra information about the context in which this element is being parsed.
public virtual void ParseElement(XElement parentElement, XElement element, IDictionary context)
{
this.Core.UnexpectedElement(parentElement, element);
}
///
/// Processes an element for the Compiler, with the ability to supply a component keypath.
///
/// Parent element of element to process.
/// Element to process.
/// Explicit key path.
/// Extra information about the context in which this element is being parsed.
public virtual ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary context)
{
this.ParseElement(parentElement, element, context);
return null;
}
///
/// Called at the end of the compilation of a source file.
///
public virtual void Finish()
{
}
}
}