Skip to content

开发常见问题-Developer FAQ

What are the dependencies?

有什么依赖?

Orchard uses a number of external libraries. They can all be found under \lib directory in your enlistment. They are also enumerated in Orchard dependencies and libraries.

Orchard使用了许多外部库。它们都可以在您的登记中的\ lib目录下找到。它们也在[Orchard依赖关系和库](Orchard-dependencies-and-libraries)中枚举。

What framework versions does Orchard support?

Orchard支持哪些框架版本?

Orchard supports the following versions of .net:

Orchard支持以下版本的.net:

Orchard Version | Framework Required

果园版|框架要求

----------------- | ------------------

  • | ------------------

Up to version 1.7 | Orchard supports .NET 4.0.

最高版本1.7 | Orchard支持.NET 4.0。

Version 1.8 | Orchard runs on .NET 4.5 and IIS 7 (or newer)

版本1.8 | Orchard在.NET 4.5和IIS 7(或更新版本)上运行

Version 1.9 | Orchard runs on .NET 4.5.1 and IIS 7 (or newer)

版本1.9 | Orchard在.NET 4.5.1和IIS 7(或更新版本)上运行

Version 1.10 | Orchard runs on .NET 4.5.2 and IIS 7 (or newer)

版本1.10 | Orchard在.NET 4.5.2和IIS 7(或更新版本)上运行

Which branch should I be using when working on the codebase?

在处理代码库时,我应该使用哪个分支?

Branches are discussed on the contributing patches page.

分支在[贡献补丁](/ Documentation / Contributing-patches#Branches)页面上讨论。

What types of extensions can I write?

我可以写什么类型的扩展?

Orchard Modules and Themes are supported. There is extensive documentation covering these topics in the main documentation index.

支持Orchard模块和主题。在[主要文档索引](/)中有大量关于这些主题的文档。

Where are Modules physically located?

模块在哪里物理位置?

The projects in the "Modules" folder are physically located under the "src\Orchard.Web\Modules" folder. This allows modules to contain ASP.NET views and static content without having to copy files between projects to be able to run the project.

“Modules”文件夹中的项目实际位于“src \ Orchard.Web \ Modules”文件夹下。这允许模块包含ASP.NET视图和静态内容,而无需在项目之间复制文件以便能够运行项目。

The Core modules are physically located under the "\src\Orchard.Web\Core" folder.

核心模块实际位于“\ src \ Orchard.Web \ Core”文件夹下。

What is a Module.txt file?

什么是Module.txt文件?

This is the module manifest. It is a YAML-format file. You can learn more about Module.txt in the manifest files guide.

这是模块清单。它是一个YAML格式的文件。您可以在[清单文件指南](清单文件)中了解有关Module.txt的更多信息。

What is the AdminMenu.cs file?

什么是AdminMenu.cs文件?

This file has an implementation of the Orchard interface called INavigationProvider. It lets modules hook themselves into the admin menu in the backend. This is typically where you declare what links should your module inject into the Admin menu and what controller actions these links invoke.

该文件有一个名为INavigationProvider的Orchard接口的实现。它允许模块将自己挂钩到后端的管理菜单中。这通常是您声明模块应该将哪些链接注入Admin菜单以及这些链接调用哪些控制器操作的位置。

What is the Permissions.cs file?

什么是Permissions.cs文件?

This file has an implementation of the Orchard interface called IPermissionProvider. It lets modules declare a set of permissions as well as attach those permissions to default Orchard roles. Once you add a new permission type to your module here, you will be able to use the Orchard authorization APIs to check that permission against the current user. You will also be able to manage which custom roles the permission belongs to in the Roles administration page.

该文件有一个名为IPermissionProvider的Orchard接口的实现。它允许模块声明一组权限,并将这些权限附加到默认的Orchard角色。在此处向模块添加新的权限类型后,您将能够使用Orchard授权API检查对当前用户的权限。您还可以在“角色”管理页面中管理权限所属的自定义角色。

How do I do authorization inside my module against current user/roles?

如何在我的模块内对当前用户/角色进行授权?

Orchard comes with a default services implementation of the IOrchardServices interface. Simply include IOrchardService in your constructor and you will get the default implementation injected. Like:

Orchard附带了IOrchardServices接口的默认服务实现。只需在构造函数中包含IOrchardService,您将获得注入的默认实现。喜欢:

public AdminController(IMyService myService, IOrchardServices orchardServices) {

            _myService = myService;

            _orchardServices = orchardServices;

}

At this point, services gives you Authorizer for authorization, Notifier for writing out notifications, ContentManager for access to the Orchard content manager and TransactionManager for handling database transactions.

此时,服务为您提供授权授权,Notifier用于写出通知,ContentManager用于访问Orchard内容管理器,TransactionManager用于处理数据库事务。

To check if the current user has a certain permission, you would simply do:

要检查当前用户是否具有特定权限,您只需执行以下操作:

Services.Authorizer.Authorize(Permissions.SomeModulePermission,

   T("Some operation failed"));

What are Core Modules?

什么是核心模块?

Core Modules are Orchard Modules you can find under \src\Orchard.Web\Core. They also constitute the Orchard.Core project in the solution. These are modules that are always enabled and come with the default Orchard installation.

核心模块是您可以在\ src \ Orchard.Web \ Core下找到的Orchard模块。它们也构成了解决方案中的Orchard.Core项目。这些是始终启用的模块,并带有默认的Orchard安装。

See "Why are Core modules modules?" and "Why are Core Modules Core Modules?" below for more detailed information.

请参阅“为什么是核心模块模块?”和“为什么核心模块核心模块?”以下是更多详细信息。

Why are Core modules modules?

为什么核心模块模块?

The difference is similar to OS concepts of monolithic vs micro-kernel: it was pretty obvious during high level design of Orchard that an extensibility point such as modules was needed. Everything else would constitute the core framework.

差异类似于单片与微内核的操作系统概念:在Orchard的高级设计中非常明显,需要一个可扩展点,如模块。其他一切都将构成核心框架。

Take the Common module for example, which introduces the BodyPart, a core concept common to many types of content types, such as blog posts or pages. Now we could've implemented this as part of the Orchard framework dll, and have modules depend on it. But then it wouldn't get the benefit of being a module, such as being able to hook up handlers, drivers, views, routes etc.

以Common模块为例,它介绍了BodyPart,这是许多类型内容类型共有的核心概念,例如博客文章或页面。现在我们可以将它作为Orchard框架dll的一部分实现,并且模块依赖于它。但是它不会获得成为模块的好处,例如能够连接处理程序,驱动程序,视图,路由等。

This also relates to MVC and areas, where everything that belongs to an area is under the same directory. It was pretty clear that the right choice was to get some core concepts out of the framework dll into a separate dll, and have them be modules.

这也涉及MVC和区域,其中属于某个区域的所有内容都在同一目录下。很明显,正确的选择是将框架dll中的一些核心概念放入一个单独的dll中,并将它们作为模块。

This is very similar to non-monolithic operating systems where parts of the core functionality is implemented as modules outside the kernel, talking to it via the same exact interfaces as the more higher level modules.

这非常类似于非单片操作系统,其中核心功能的一部分被实现为内核之外的模块,通过与更高级别模块相同的精确接口与之通信。

Why are Core Modules Core Modules?

为什么核心模块核心模块?

Now that we want core concepts to be implemented as modules, why not put them into the modules directory along with the rest of the more obvious Orchard modules, such as the comments module. Well, this time it's about dependencies. In Orchard, modules that are in the modules directory can be disabled, uninstalled or otherwise updated in a breaking way.

现在我们希望将核心概念实现为模块,为什么不将它们与其他更明显的Orchard模块(例如comments模块)一起放入模块目录中。好吧,这一次是依赖关系。在Orchard中,可以以中断方式禁用,卸载或以其他方式更新模块目录中的模块。

We prefer modules that are self-contained and don't require other non-core modules as dependencies, as much as possible. That's part of the entire dynamism behind the content type architecture. Pages and Blog posts, which belong to Pages and Blog modules, don't reference Comments or Tags modules, but it's possible to attach comments or tags to pages and blogposts.

我们更喜欢自包含的模块,并且尽可能不需要其他非核心模块作为依赖项。这是内容类型架构背后的整个活力的一部分。页面和博客帖子属于Pages和Blog模块,不引用评论或标签模块,但可以将评论或标签附加到页面和博客帖子。

This decoupled behavior is ensured by the underlying content type architecture and not by direct reference from one or the other modules. Core modules are part of the Orchard framework and it's ok for modules to depend on them. They will be distributed by us and for all practical purposes are integral parts of the Orchard framework. Modules can depend on them and directly access their public surface.

这种解耦行为由底层内容类型体系结构确保,而不是由一个或其他模块直接引用。核心模块是Orchard框架的一部分,模块可以依赖它们。它们将由我们分发,并且出于所有实际目的,它们是Orchard框架的组成部分。模块可以依赖于它们并直接访问它们的公共表面。

How do I write and run tests?

我如何编写和运行测试?

Orchard comes with a solution folder called Tests. This hosts 2 types of tests:

Orchard附带了一个名为Tests的解决方案文件夹。这包含两种类型的测试:

  • Unit Tests: These are NUnit test fixtures. To write a fixture for a module, simply create a new directory under Orchard.Tests.Modules and populate it with your tests.

  • 单元测试:这些是NUnit测试装置。要为模块编写夹具,只需在Orchard.Tests.Modules下创建一个新目录,并用测试填充它。

  • Integration Tests: These are also NUnit tests, generated using SpecFlow (http://www.specflow.org) .feature files. Your integration tests would go under Orchard.Specs and there are a multitude of examples there you can look at if you are new to the BDD approach.

  • 集成测试:这些也是使用SpecFlow([http://www.specflow.org](http://www.specflow.org)).feature文件生成的NUnit测试。您的集成测试将在Orchard.Specs下进行,如果您不熟悉BDD方法,可以查看大量示例。

Running the unit tests is a matter of right clicking the solution or appropriate project and choose Run Unit Tests.

运行单元测试是右键单击解决方案或相应项目并选择“运行单元测试”。

Note

!注意

this applies to writing tests for the modules that come with the standard source code distribution of Orchard.

To write code for your own modules you should work in your own separate project. You can use the orchard scaffolding command codegen moduletests <module-name> to set up test projects for your own modules.

要为自己的模块编写代码,您应该在自己的单独项目中工作。您可以使用[orchard scaffolding command](命令行脚手架)codegen moduletests <module-name>为您自己的模块设置测试项目。

How do I contribute my changes to Orchard?

如何将我的更改贡献给Orchard?

Contributing changes to Orchard are discussed on the contributing patches page.

在[贡献补丁](/ Documentation / Contributing-patches#Branches)页面上讨论了对Orchard的贡献变化。

How to build a WCF service that exposes Orchard functionality?

如何构建暴露Orchard功能的WCF服务?

To host a WCF Service in Orchard, with all of its goodies coming from IoC you have to:

要在Orchard中托管WCF服务,其所有好处都来自IoC,您必须:

Create a SVC file for your service with the new Orchard Host Factory:

使用新的Orchard Host Factory为您的服务创建SVC文件:

<%@ ServiceHost Language="C#" Debug="true"

Service="Orchard.Service.Services.IService, Orchard.Service"

Factory="Orchard.Wcf.OrchardServiceHostFactory, Orchard.Framework" %>

Register the service normally as an IDependency.

正常注册服务作为IDependency。

using System.ServiceModel;



namespace Orchard.Service.Services {

  [ServiceContract]

  public interface IService : IDependency {

    [OperationContract]

    string GetUserEmail(string username);

  }

}

Provide implementation (i.e.: Service : IService).

提供实施(即:服务:IService)。

What's in App_Data?

App_Data中有什么?

The App_Data folder is used to store various kinds of data. Contents of App_Data are never served. The contents are organized this way:

App_Data文件夹用于存储各种数据。永远不会提供“App_Data”的内容。内容以这种方式组织:

  • File:cache.dat is a cache XML document describing what features are enabled for each tenant in the site. This being only a cache, modifying it may have unpredictable results.

  • 文件: cache.dat 是一个缓存XML文档,描述了为站点中的每个租户启用了哪些功能。这只是一个缓存,修改它可能会产生不可预测的结果。

  • File:hrestart.txt stands for Host Restart. It is a file that is touched by the system to indicate a need to restart the application.

  • 文件: hrestart.txt 代表主机重启。它是系统触及的文件,表示需要重新启动应用程序。

  • Folder:Dependencies is used by dynamic compilation to store compiled dlls and has an XML file, dependencies.xml that tracks how each module was compiled (dynamically or not).

  • 文件夹:依赖项由动态编译用于存储已编译的dll,并具有XML文件,dependencies.xml,用于跟踪每个模块的编译方式(动态与否)。

  • Folder:Exports contains export XML files generated by the import/export feature.

  • 文件夹:导出包含导入/导出功能生成的导出XML文件。

  • Folder:Localization contains localization .po files.

  • 文件夹:本地化包含本地化.po文件。

  • Folder:Logs contains log files.

  • 文件夹:日志包含日志文件。

  • Folder:RecipeQueue is used during setup to queue the recipes to execute.

  • 文件夹: RecipeQueue 在安装过程中用于对要执行的配方进行排队。

  • Folder:Sites contains one folder per tenant. The default tenant is in the Default folder, which is all there is if no tenant was created. Each folder contains the following:

  • 文件夹:网站每个租户包含一个文件夹。默认承租人位于默认文件夹中,如果没有创建承租人,则该文件夹就是默认承租人。每个文件夹包含以下内容:

    • mappings.bin is a binary serialized cache of nHibernate mappings.

    • Orchard.sdf is the SQL CE database file for the tenant.

    • reports.dat is a legacy log file.

    • Settings.txt describes the low-level settings for the tenant (database provider, connection string, etc.)

    • *.settings.xml - You will see one of these per search index you have configured in the admin panel. They hold configuration settings for the current state of that index.

    • Folder: Indexes - Used by the Lucene module to store search index cache files.

  • Folder:Warmup contains cached versions of pages generated by the warmup module, and a warmup.txt file that contains the timestamp for the last warmup file generation.

  • 文件夹:预热包含由预热模块生成的页面的缓存版本,以及包含上次预热文件生成的时间戳的warmup.txt文件。

Understanding bug status and triage

了解错误状态和分类

When you submit a bug, the team (or anybody subscribing to notifications) receives an e-mail. We do regular triage meetings with a small committee, sometimes as often as daily and usually at least once a week.

当您提交错误时,团队(或任何订阅通知的人)会收到一封电子邮件。我们定期与一个小型委员会进行分诊会议,有时候每天都会进行,通常每周至少一次。

When we do triage, we make a query that returns all bugs in "Proposed" state, ordered by number of votes. This means that we are always looking at the most voted bugs first. If you care about a bug, you should vote for it, and it won't fall on deaf ears.

当我们进行分类时,我们会生成一个查询,返回“建议”状态下的所有错误,按投票数排序。这意味着我们总是首先查看投票最多的错误。如果你关心一个bug,你应该投票给它,它不会被置若罔闻。

A bug that is still in "Proposed" state has not been triaged yet. When we look at a bug, several things can happen. We may close it if it doesn't reproduce, if it's by design or if it was fixed since submitted. We may ask for more information (and leave it in "Proposed" state). Or finally, we may move it to the "Active" bucket.

仍处于“建议”状态的错误尚未进行分类。当我们查看错误时,可能会发生一些事情。我们可以关闭它,如果它不复制,如果它是设计或自提交后它是固定的。我们可能会要求提供更多信息(并将其保留在“建议”状态)。或者最后,我们可以将其移至“活动”桶。

A bug that is in "Active" state has been triaged and should have been assigned a release. The release usually is one of the planned releases. Planned releases are usually the ones we are currently working on, plus a "Future Versions" release that we use for bugs and features that we want to handle but don't think we can do in the current cycle. The "Assigned to" field is only set when the bug is scheduled to be fixed in the current iteration or cycle. If it's in "Future Versions" it is usually unassigned.

处于“活动”状态的错误已被分类,应该已分配一个版本。该版本通常是计划发布的版本之一。计划版本通常是我们目前正在处理的版本,加上我们用于处理我们想要处理的错误和功能的“未来版本”版本,但我们认为我们无法在当前周期中执行此操作。只有当错误被安排在当前迭代或循环中修复时,才会设置“已分配给”字段。如果它在“未来版本”中,它通常是未分配的。

Impact is usually set during triage but a "Low" value does not necessarily mean much: this is the default value so it might just mean that it hasn't been touched. It's OK to investigate with the team on the impact of a bug you care about.

影响通常在分类期间设置,但“低”值并不一定意味着很多:这是默认值,因此它可能只是意味着它没有被触及。可以与团队一起调查您关心的bug的影响。

Developer Troubleshooting

Developer Troubleshooting

  • Record Names: Your implementations of the ContentPartRecords shouldn't have properties that are known keywords to NHibernate. Examples include Identity, Version.

  • 记录名称:您的ContentPartRecords实现不应具有NHibernate已知关键字的属性。示例包括Identity,Version。