Orchard:IContentManager
这是Orchard管理Content的接口,定义了下面接口:
IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions();
- ContentItem New(string contentType);
新建一个未持久化的ContentItem - void Create(ContentItem contentItem);
ContentItem持久化(ContentItem必须填充好了数据) - void Create(ContentItem contentItem, VersionOptions options);
持久化为指定的版本 - ContentItem Get(int id);
获取指定的ContentItem - ContentItem Get(int id, VersionOptions options);
指定了版本 - ContentItem Get(int id, VersionOptions options, QueryHints hints);
- IEnumerable<ContentItem> GetAllVersions(int id);
获取某个ContentItem的所有版本 - IEnumerable<T> GetMany<T>(IEnumerable<int> ids, VersionOptions options, QueryHints hints) where T : class, IContent;
- IEnumerable<T> GetManyByVersionId<T>(IEnumerable<int> versionRecordIds, QueryHints hints) where T : class, IContent;
- void Publish(ContentItem contentItem);
发布 - void Unpublish(ContentItem contentItem);
- 取消发布
- void Remove(ContentItem contentItem);
- 删除
- void Index(ContentItem contentItem, IDocumentIndex documentIndex);
索引 - XElement Export(ContentItem contentItem);
导出 - void Import(XElement element, ImportContentSession importContentSession);
导入 - void Flush();
持久化所有ContentItem - void Clear();
清除所有引用的Item - IContentQuery<ContentItem> Query();
返回IContentQuery,用于查询ContentItem. - IHqlQuery HqlQuery();
使用IHqlQuery进行查询 - ContentItemMetadata GetItemMetadata(IContent contentItem);
获取Item元数据 - IEnumerable<GroupInfo> GetEditorGroupInfos(IContent contentItem);
- IEnumerable<GroupInfo> GetDisplayGroupInfos(IContent contentItem);
- GroupInfo GetEditorGroupInfo(IContent contentItem, string groupInfoId);
- GroupInfo GetDisplayGroupInfo(IContent contentItem, string groupInfoId);
- dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "");
创建指定ContentItem的显示Shape - dynamic BuildEditor(IContent content, string groupId = "");
创建编辑Shape - dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "");
更新
VersionOptions类定义了一些静态属性及Is的各种状态:
public class VersionOptions { public static VersionOptions Latest { get { return new VersionOptions { IsLatest = true }; } } public static VersionOptions Published { get { return new VersionOptions { IsPublished = true }; } } public static VersionOptions Draft { get { return new VersionOptions { IsDraft = true }; } } public static VersionOptions DraftRequired { get { return new VersionOptions { IsDraft = true, IsDraftRequired = true }; } } public static VersionOptions AllVersions { get { return new VersionOptions { IsAllVersions = true }; } } public static VersionOptions Number(int version) { return new VersionOptions { VersionNumber = version }; } public static VersionOptions VersionRecord(int id) { return new VersionOptions { VersionRecordId = id }; } public bool IsLatest { get; private set; } public bool IsPublished { get; private set; } public bool IsDraft { get; private set; } public bool IsDraftRequired { get; private set; } public bool IsAllVersions { get; private set; } public int VersionNumber { get; private set; } public int VersionRecordId { get; private set; } }