如何添加C#code到一个新的果园CMS主题 [英] How to add C# code to a new Orchard CMS theme

查看:100
本文介绍了如何添加C#code到一个新的果园CMS主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现果园 IShapeTableProvider,以添加一个备用的主列表形状。我也做了以下内容:

I would like to implement the Orchard IShapeTableProvider, in order to add an alternate for the main List shape. I have done the following:

Orchard.Source.1.8.zip ,构建VS 2013 ,并创建通过code产生一个​​新的主题:

Download Orchard.Source.1.8.zip, build in VS 2013, and create a new theme via code generation:

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

添加以下code到我的主题,在主题> My.FirstTheme> code> ListShapeProvider.cs文件。

Add the following code to my theme in the Themes > My.FirstTheme > Code > ListShapeProvider.cs file.

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.Web。调试器不打System.Diagnostics.Debugger.Break()。

Clean and build the Orchard solution, then debug Orchard.Web. The debugger does not hit System.Diagnostics.Debugger.Break().

我已阅读果园用变形通过果园的仁慈的独裁者。

I have read Orchard shapeshifting by Orchard's Benevolent Dictator.

此外,我已经安装,建造和运行Contoso的主题,作为一个例子实施 IShapeTableProvider 的。 IShapeTableProvider 的实施是在ContentShapeProvider.cs文件。 Contoso的主题还包括具有ContentShapeProvider.cs文件作为编译项目一个Contoso.csproj文件。

Further, I have installed, built, and run the Contoso theme as an example implementation of IShapeTableProvider. The implementation of IShapeTableProvider is in the ContentShapeProvider.cs file. The Contoso theme also includes a Contoso.csproj file that has the ContentShapeProvider.cs file as a Compile Item.

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

这是我创建不具有的.csproj文件中的新主题。我认为缺少的.csproj文件解释了为什么我的ListShapeProvider.cs断点没有执行。

The new theme that I created does not have a .csproj file. I think the missing .csproj file explains why my ListShapeProvider.cs breakpoint is not executing.

我应该创造我的主题.csproj的文件?是否有另一种推荐方式,包括在主题C#?举例来说,我应该使用APP_ code文件夹?

Should I create a .csproj file for my theme? Is there another recommended way to include C# in the theme? For instance, should I use an App_Code folder?

推荐答案

在Orchard.exe code一代,添加 /的createProject:真。这会为你生成一个.csproj的文件。例如。

In the Orchard.exe code generation, add /CreateProject:true. This will generate a .csproj file for you. E.g.

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

现在,当您添加ListShapeProvider.cs文件,Visual Studio将自动为下面进入My.FirstTheme.csproj文件。

Now when you add a ListShapeProvider.cs file, Visual Studio will automatically as the following entry to the My.FirstTheme.csproj file.

<ItemGroup>
  <Compile Include="ListShapeProvider.cs" />
</ItemGroup>

这篇关于如何添加C#code到一个新的果园CMS主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆