Orchard:IContentManager

这是Orchard管理Content的接口,定义了下面接口:

IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions();

  1. ContentItem New(string contentType);
    新建一个未持久化的ContentItem
  2. void Create(ContentItem contentItem);
    ContentItem持久化(ContentItem必须填充好了数据)
  3. void Create(ContentItem contentItem, VersionOptions options);
    持久化为指定的版本
  4. ContentItem Get(int id);
    获取指定的ContentItem
  5. ContentItem Get(int id, VersionOptions options);
    指定了版本
  6. ContentItem Get(int id, VersionOptions options, QueryHints hints);
  7. IEnumerable<ContentItem> GetAllVersions(int id);
    获取某个ContentItem的所有版本
  8. IEnumerable<T> GetMany<T>(IEnumerable<int> ids, VersionOptions options, QueryHints hints) where T : class, IContent;
  9. IEnumerable<T> GetManyByVersionId<T>(IEnumerable<int> versionRecordIds, QueryHints hints) where T : class, IContent;
  10. void Publish(ContentItem contentItem);
    发布
  11. void Unpublish(ContentItem contentItem);
  12. 取消发布
  13. void Remove(ContentItem contentItem);
  14. 删除
  15. void Index(ContentItem contentItem, IDocumentIndex documentIndex);
    索引
  16. XElement Export(ContentItem contentItem);
    导出
  17. void Import(XElement element, ImportContentSession importContentSession);
    导入
  18. void Flush();
    持久化所有ContentItem
  19. void Clear();
    清除所有引用的Item
  20. IContentQuery<ContentItem> Query();
    返回IContentQuery,用于查询ContentItem.
  21. IHqlQuery HqlQuery();
    使用IHqlQuery进行查询
  22. ContentItemMetadata GetItemMetadata(IContent contentItem);
    获取Item元数据
  23. IEnumerable<GroupInfo> GetEditorGroupInfos(IContent contentItem);
  24. IEnumerable<GroupInfo> GetDisplayGroupInfos(IContent contentItem);
  25. GroupInfo GetEditorGroupInfo(IContent contentItem, string groupInfoId);
  26. GroupInfo GetDisplayGroupInfo(IContent contentItem, string groupInfoId);
  27. dynamic BuildDisplay(IContent content, string displayType = "", string groupId = "");
    创建指定ContentItem的显示Shape
  28. dynamic BuildEditor(IContent content, string groupId = "");
    创建编辑Shape
  29. 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; }
    }
posted @ 2012-08-17 12:24  commanderss  阅读(718)  评论(0编辑  收藏  举报