// 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.Core.Preprocess
{
///
/// Context for an if statement in the preprocessor.
///
internal class IfContext
{
private bool keep;
///
/// Creates a default if context object, which are used for if's within an inactive preprocessor block
///
public IfContext()
{
this.WasEverTrue = true;
this.IfState = IfState.If;
}
///
/// Creates an if context object.
///
/// Flag if context is currently active.
/// Flag if context is currently true.
/// State of context to start in.
public IfContext(bool active, bool keep, IfState state)
{
this.Active = active;
this.keep = keep;
this.WasEverTrue = keep;
this.IfState = IfState.If;
}
///
/// Gets and sets if this if context is currently active.
///
/// true if context is active.
public bool Active { get; set; }
///
/// Gets and sets if context is current true.
///
/// true if context is currently true.
public bool IsTrue
{
get
{
return this.keep;
}
set
{
this.keep = value;
if (this.keep)
{
this.WasEverTrue = true;
}
}
}
///
/// Gets if the context was ever true.
///
/// True if context was ever true.
public bool WasEverTrue { get; private set; }
///
/// Gets the current state of the if context.
///
/// Current state of context.
public IfState IfState { get; set; }
}
}