Visual studion 2013(专业版)Razor IntelliSense无法用于动态对象

时间:2016-10-26 08:44:48

标签: c# visual-studio razor intellisense umbraco7

上周我的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似乎不存在。

enter image description here

我已经安装了resharpher,当我去resharper时>选项并切换到resharper IntelliSense我从对象获取成员,看起来像我在其他地方使用的成员,但resharper不太确定。

enter image description here

我知道ChildrenAsList成员(这是我需要的)可用于动态galleryAlbum对象,但为什么我的IntelliSense没有告诉我这个。

enter image description here

我注意到的另一件事是我的IntelliSense不断停止工作,无论它处于vs还是resharper模式,这也让我相信有些东西与这个安装有关。要修复我要么必须关闭代码文件或项目本身。因此,考虑到上述问题,我有以下问题

  1. vs IntelliSense无法使用的标准行为 umbraco razor视图中的动态对象?
  2. 为什么基础对象成员在使用resharper IntelliSense时会显示 而不是在使用VS IntelliSense时?
  3. 为什么所有IntelliSense都会一直停止工作?
  4. 如果有人对上述内容有任何信息,那么我会非常感激。我试过了

    1. 通过导入和导出wizzard重置所有用户设置
    2. 选中&#39;自动列出会员&#39; &安培; &#39;参数信息&#39;在声明中 完成vs选项
    3. 没有运气。

      我还向umbraco社区https://our.umbraco.org/forum/using-umbraco-and-getting-started/80911-razor-visual-studio-intellisense-not-working-for-dynamic-objects

      提出了这个问题

1 个答案:

答案 0 :(得分:3)

动态对象可以是任何东西,它们在运行时被解析。

而不是使用Umbraco.Media尝试使用Umbraco.TypedMedia来获取强类型模型。那样你可以使用intellisense