|
//===========================================
// MVC# Framework | www.MVCSharp.org |
// ------------------------------------------
// Copyright (C) 2008 www.MVCSharp.org |
// All rights reserved. |
//===========================================
using System;
using System.Text;
using System.Reflection;
namespace MVCSharp.Core.Configuration.Views
{
#region Documentation
/// <summary>
/// This IViewInfosProvider implementation generates <see cref="ViewInfo"/> objects
/// from <see cref="ViewAttribute"/> attributes.
/// </summary>
#endregion
public class DefaultViewInfosProvider : IViewInfosProvider
{
#region Documentation
/// <summary>
/// Generates <see cref="ViewInfo"/> objects from <see cref="ViewAttribute"/> attributes
/// found in the given assembly.
/// </summary>
#endregion
public ViewInfosByTaskCollection GetFromAssembly(Assembly assembly)
{
ViewInfosByTaskCollection result = new ViewInfosByTaskCollection();
foreach (Type t in assembly.GetTypes())
foreach (ViewAttribute viewAttr in t.GetCustomAttributes(typeof(ViewAttribute), false))
{
if (result[viewAttr.TaskType] == null)
result[viewAttr.TaskType] = new ViewInfoCollection();
result[viewAttr.TaskType][viewAttr.ViewName] = newViewInfo(t, viewAttr);
}
return result;
}
#region Documentation
/// <summary>
/// Creates a ViewInfo object by a given ViewAttribute instance.
/// </summary>
#endregion
protected virtual ViewInfo newViewInfo(Type viewType, ViewAttribute viewAttr)
{
return new ViewInfo(viewType);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Oleg Zhukov, born and living in Russia is Lead Engineer and Project Manager in a company which provides business software solutions. He has graduated from Moscow Institute of Physics and Technology (MIPT) (department of system programming) and has got a M.S. degree in applied physics and mathematics. His research and development work concerns architectural patterns, domain-driven development and systems analysis. Being the adherent of agile methods he applies them extensively in the projects managed by him.