// 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.NamespaceRef"/>.
/// </summary>
public class NamespaceRefVM : SymbolicRefVM
{
#region /* STATICS */
internal static void AddViewModelMapping()
{
CreateViewModel.Add(typeof(NamespaceRef),
delegate(CodeObject codeObject, bool isDescription, Dictionary<CodeObject, CodeObjectVM> dictionary) { return new NamespaceRefVM((NamespaceRef)codeObject, dictionary); });
}
#endregion
#region /* CONSTRUCTORS */
/// <summary>
/// Create a view model instance for the specified <see cref="CodeDOM.NamespaceRef"/>.
/// </summary>
public NamespaceRefVM(NamespaceRef namespaceRef, Dictionary<CodeObject, CodeObjectVM> dictionary)
: base(namespaceRef, dictionary)
{ }
#endregion
#region /* PROPERTIES */
/// <summary>
/// The underlying <see cref="CodeDOM.NamespaceRef"/> model.
/// </summary>
public NamespaceRef NamespaceRef
{
get { return (NamespaceRef)CodeObject; }
}
#endregion
#region /* METHODS */
#endregion
#region /* RENDERING */
protected override void RenderReferenceDescription(CodeRenderer renderer, object obj)
{
base.RenderReferenceDescription(renderer, obj);
// If it's a reference to a RootNamespace, render the name of the referenced assembly, if appropriate
if (obj is RootNamespace)
{
Reference parentReference = ((RootNamespace)obj).ParentReference;
if (parentReference != null)
{
LoadedAssembly loadedAssembly = parentReference.LoadedAssembly;
if (loadedAssembly is MonoCecilLoadedAssembly)
RenderReferencedAssembly(renderer, "alias of", ((MonoCecilLoadedAssembly)loadedAssembly).AssemblyDefinition);
else if (loadedAssembly is ReflectionLoadedAssembly)
RenderReferencedAssembly(renderer, "alias of", ((ReflectionLoadedAssembly)loadedAssembly).Assembly);
}
}
}
#endregion
}
}