1

介绍问题

我想实现果园以便为主要形状IShapeTableProvider,添加替代品。List我做了以下事情:

下载Orchard.Source.1.8.zip,在 VS 2013 中构建,并通过代码生成创建一个新主题:

  orchard.exe
  feature enable Orchard.CodeGeneration
  codegen theme My.FirstTheme
  theme enable My.FirstTheme

在 Themes > My.FirstTheme > Code > ListShapeProvider.cs 文件中将以下代码添加到我的主题中。

namespace Themes.My.FirstTheme.Code
{
    using Orchard.Autoroute.Models;
    using Orchard.ContentManagement;
    using Orchard.DisplayManagement.Descriptors;
    public class ListShapeProvider : IShapeTableProvider
    {
        public void Discover(ShapeTableBuilder builder)
        {
            System.Diagnostics.Debugger.Break(); // * not hit
        }
    }
}

清理并构建 Orchard 解决方案,然后调试 Orchard.Web。调试器未命中 System.Diagnostics.Debugger.Break()。

搜索和研究

我读过Orchard的仁慈独裁者的 Orchard shapeshifting。

此外,我已经安装、构建和运行 Contoso 主题作为IShapeTableProvider. 的实现IShapeTableProvider在 ContentShapeProvider.cs 文件中。Contoso 主题还包括一个 Contoso.csproj 文件,该文件将 ContentShapeProvider.cs 文件作为编译项。

<ItemGroup>
   <Compile Include="Code\ContentShapeProvider.cs" />
 </ItemGroup>

我创建的新主题没有 .csproj 文件。我认为丢失的 .csproj 文件解释了为什么我的 ListShapeProvider.cs 断点没有执行。

我应该为我的主题创建一个 .csproj 文件吗?是否有另一种推荐的方式在主题中包含 C#?例如,我应该使用 App_Code 文件夹吗?

4

2 回答 2

1

在 Orchard.exe 代码生成中,添加/CreateProject:true. 这将为您生成一个 .csproj 文件。例如

orchard.exe
feature enable Orchard.CodeGeneration
codegen theme My.FirstTheme /CreateProject:true
theme enable My.FirstTheme

现在,当您添加 ListShapeProvider.cs 文件时,Visual Studio 将自动作为 My.FirstTheme.csproj 文件的以下条目。

<ItemGroup>
  <Compile Include="ListShapeProvider.cs" />
</ItemGroup>
于 2014-05-12T19:18:39.350 回答
0

You can add /IncludeInsolution:true too in your codegen theme My.FirstTheme /CreateProject:true
It will add your theme project under the Themes top level folder.

于 2014-06-14T07:38:02.963 回答