// 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.Case"/>.
/// </summary>
public class CaseVM : SwitchItemVM
{
#region /* STATICS */
internal static void AddViewModelMapping()
{
CreateViewModel.Add(typeof(Case),
delegate(CodeObject codeObject, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary) { return new CaseVM((Case)codeObject, isDescription, dictionary); });
}
#endregion
#region /* FIELDS */
protected ExpressionVM _constantExpressionVM;
#endregion
#region /* CONSTRUCTORS */
/// <summary>
/// Create a view model instance for the specified <see cref="CodeDOM.Case"/>.
/// </summary>
public CaseVM(Case @case, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary)
: base(@case, isDescription, dictionary)
{
_constantExpressionVM = (ExpressionVM)CreateVM(@case.ConstantExpression, isDescription, dictionary);
}
#endregion
#region /* PROPERTIES */
/// <summary>
/// The underlying <see cref="CodeDOM.Case"/> model.
/// </summary>
public Case Case
{
get { return (Case)CodeObject; }
}
/// <summary>
/// The constant <see cref="ExpressionVM"/> of the <see cref="CaseVM"/>.
/// </summary>
public ExpressionVM ConstantExpressionVM
{
get { return _constantExpressionVM; }
}
#endregion
#region /* METHODS */
#endregion
#region /* RENDERING */
protected override void RenderArgument(CodeRenderer renderer, RenderFlags flags)
{
if (_constantExpressionVM != null)
_constantExpressionVM.Render(renderer, flags);
}
public override void UnRender()
{
if (_constantExpressionVM != null)
_constantExpressionVM.UnRender();
base.UnRender();
}
#endregion
}
}