最近,我开始将FubuMVC 项目从 2010 年 5 月/6 月之前的 FubuMVC 框架版本更新到最新版本。
我遇到的最大障碍之一是如何配置 FubuControls 和它们使用的显示模型,以便我可以在Site.Master页面中呈现这些控件。FubuException我无法解决的一个错误消息是:
FubuMVC Error 2102:
Unknown input type ResourceDisplay
从第 69 行 的方法FindUniqueByInputType中抛出。FubuMVC.Core.Registration.Querying.ChainResolver
这是我的 Web 项目的 Global.asax.cs:
public class Global : FubuStructureMapApplication
{
protected override void InitializeStructureMap(IInitializationExpression ex)
{
Bootstrapper.ScanAndRegisterTypesForStructureMap(ex, new List<Registry>
{
new WebAppWebRegistry(),
new AppSettingProviderRegistry()
});
setup_service_locator();
}
private static void setup_service_locator()
{
ServiceLocator.SetLocatorProvider(() => new StructureMapServiceLocator(ObjectFactory.Container));
}
public override FubuRegistry GetMyRegistry()
{
return new WebAppFubuRegistry();
}
}
这是我的FubuRegistry:
public class WebAppFubuRegistry : FubuRegistry
{
public WebAppFubuRegistry()
{
IncludeDiagnostics(true);
Services(x => x.SetServiceIfNone<IWebAppSecurityContext, WebAppSecurityContext>());
Applies.ToThisAssembly()
.ToAssemblyContainingType<HomeController>();
Actions
.IncludeTypesNamed(x => x.EndsWith("Controller"));
Routes
.UrlPolicy<WebAppUrlPolicy>()
.IgnoreControllerNamespaceEntirely()
.ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Perform"), "POST");
Views
.TryToAttach(x=>
{
x.by<ViewAndActionInDifferentFolders>();
x.by_ViewModel_and_Namespace_and_MethodName();
x.by_ViewModel_and_Namespace();
x.by_ViewModel();
});
/* Irrelevant behaviors are added to configuration here */
RegisterPartials(x => x.For<ResourceDisplay>().Use<ResourceTracker>());
//this.UseDefaultHtmlConventions();
//HomeIs<HomeController>(x => x.Index());
}
}
更多信息和更新:
我发现的部分问题是,当我更新项目时,我改变了:
public class SiteMasterView : FubuMasterPage<EmptyModel>, IFubuPage<EmptyModel>{ }
到
public class SiteMasterView : FubuMasterPage
这意味着扩展功能RenderPartial<TViewModel>(this IFubuPage<TViewModel> viewPage)不再可以从SiteMasterView.
这是旧的和无效的RenderPartial<TViewModel>Call in Site.Master:
<%= this.RenderPartial().Using<ResourceTracker>().For(Get<UserResources>().Resources)%>
所以,我认为此时我考虑尝试创建自己的 RenderPartial 扩展函数,该函数可以使用FubuMasterPage(而不仅仅是使用IFubuPage<EmptyModel>)。但我想我不妨更新我对 FubuFramework 的使用并使用void Partial<TInputModel>(this IFubuPage page) where TInputModel : class;扩展功能而不是旧的更冗长的版本。
新的召唤:
<% this.Partial<ResourceDisplay>(); %>
那时我开始ChainResolver遇到. 我还尝试在我的. 但是我没有运气通过. IFubuCommandResourceDisplayFubuRegistryChainResolver
向 FubuFramework 注册 FubuControls 及其视图模型的首选方法是什么?
如何解决上述错误?