namespace GameLibrary.Framework{
using System;
using System.Collections.Generic;
using Caliburn.Core;
using Caliburn.PresentationFramework.ApplicationModel;
using Microsoft.Practices.ServiceLocation;
public class DTOViewStrategy : DefaultViewStrategy
{
public DTOViewStrategy(IAssemblySource assemblySource, IServiceLocator serviceLocator)
: base(assemblySource, serviceLocator) {}
protected override IEnumerable<string> GetTypeNamesToCheck(Type modelType, string context)
{
var modelTypeFullName = modelType.FullName;
if(modelTypeFullName.StartsWith("GameLibrary.Model") && modelTypeFullName.EndsWith("DTO"))
{
var viewTypeName = "GameLibrary.Views." + modelType.Name.Replace("DTO", "View");
return new[]
{
viewTypeName
};
}
var results = base.GetTypeNamesToCheck(modelType, context);
return results;
}
}
}
|