// The Nova Project by Ken Beckett.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php
using System.Collections.Generic;
using Nova.CodeDOM;
namespace Nova.UI
{
/// <summary>
/// The view model for a <see cref="CodeDOM.DoWhile"/>.
/// </summary>
public class DoWhileVM : StatementVM
{
#region /* STATICS */
internal static void AddViewModelMapping()
{
CreateViewModel.Add(typeof(DoWhile),
delegate(CodeObject codeObject, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary) { return new DoWhileVM((DoWhile)codeObject, dictionary); });
}
#endregion
#region /* CONSTRUCTORS */
/// <summary>
/// Create a view model instance for the specified <see cref="CodeDOM.DoWhile"/>.
/// </summary>
public DoWhileVM(DoWhile doWhile, Dictionary<CodeObject, CodeObjectVM> dictionary)
: base(doWhile, dictionary)
{ }
#endregion
#region /* PROPERTIES */
/// <summary>
/// The underlying <see cref="CodeDOM.DoWhile"/> model.
/// </summary>
public DoWhile DoWhile
{
get { return (DoWhile)CodeObject; }
}
/// <summary>
/// The conditional <see cref="ExpressionVM"/>.
/// </summary>
public ExpressionVM Conditional
{
get { return ((WhileVM)ParentVM).ConditionalVM; }
}
#endregion
#region /* RENDERING */
protected override void RenderArgument(CodeRenderer renderer, RenderFlags flags)
{
ExpressionVM conditional = Conditional;
if (conditional != null)
conditional.Render(renderer, flags);
}
public override void Render(CodeRenderer renderer, RenderFlags flags)
{
base.Render(renderer, flags | (ParentVM is WhileVM ? RenderFlags.NoBorder : 0));
}
#endregion
}
}