上周我的visual studio 2013专业版遇到了一些麻烦,这意味着我不得不重新安装该软件。我已经设置了所有内容,我注意到,在umbraco 7项目中,IntelliSense不能用于我的剃刀文件中的动态对象。我可能错了,但我可以知道这在重新安装VS之前曾经工作过。
在umbraco razor视图中考虑以下代码
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
//gets the home page using doc type alias (root node)
var siteRoot = Model.Content.AncestorOrSelf("homePage");
//gets the about us page using doc type alias
var portfolioPage = siteRoot.Descendant("portfolioPage");
//gets the gallery page using doc type alias
var galleryPage = siteRoot.Descendant("galleryPage");
var imagesToDisplay = portfolioPage.HasValue("imageAmount") ? portfolioPage.GetPropertyValue<int>("imageAmount") : 2;
}
<!-- .container -->
<div class="container">
<div class="post-heading-center">
<h2>@(portfolioPage.HasValue("heading") ? portfolioPage.GetPropertyValue("heading") : portfolioPage.Name)</h2>
</div>
<nav>
<a href="#">All Work</a>
<!--get gallery albums-->
@foreach (var type in galleryPage.Children)
{
var galleryAlbum = Umbraco.Media(type.GetPropertyValue<int>("image"));
if (galleryAlbum.ChildrenAsList.Count() != 0)
{
<a href="#" data-filter=".class-@type.Id">@type.Name</a>
}
}
</nav>
</div>
使用visual studio IntelliSense时,我没有选项和消息通知我它是一个动态表达式,它将在运行时解析。 IntelliSense似乎不存在。
我已经安装了resharpher,当我去resharper时>选项并切换到resharper IntelliSense我从对象获取成员,看起来像我在其他地方使用的成员,但resharper不太确定。
我知道ChildrenAsList成员(这是我需要的)可用于动态galleryAlbum对象,但为什么我的IntelliSense没有告诉我这个。
我注意到的另一件事是我的IntelliSense不断停止工作,无论它处于vs还是resharper模式,这也让我相信有些东西与这个安装有关。要修复我要么必须关闭代码文件或项目本身。因此,考虑到上述问题,我有以下问题
如果有人对上述内容有任何信息,那么我会非常感激。我试过了
没有运气。
提出了这个问题答案 0 :(得分:3)
动态对象可以是任何东西,它们在运行时被解析。
而不是使用Umbraco.Media
尝试使用Umbraco.TypedMedia
来获取强类型模型。那样你可以使用intellisense