当前位置: 首页>>代码示例>>C#>>正文


C# IContent.IsPublished方法代码示例

本文整理汇总了C#中IContent.IsPublished方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.IsPublished方法的具体用法?C# IContent.IsPublished怎么用?C# IContent.IsPublished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContent的用法示例。


在下文中一共展示了IContent.IsPublished方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyConnectorCriteria

 private IContentQuery<ConnectorPart, ConnectorPartRecord> ApplyConnectorCriteria(IContent left, ConnectorCriteria criteria, IContentQuery<ConnectorPart, ConnectorPartRecord> query) {
     if (criteria == ConnectorCriteria.Auto)
         criteria = (!left.IsPublished() && left.ContentItem.VersionRecord != null && left.ContentItem.VersionRecord.Latest) ? ConnectorCriteria.Drafts : ConnectorCriteria.Published;
     switch (criteria) {
         case ConnectorCriteria.Published:
             // Always show published
             query = query.ForVersion(VersionOptions.Published);
             break;
         case ConnectorCriteria.Drafts:
             // Drafted item, get Latest (but exclude deleted)
             query = query.ForVersion(VersionOptions.Latest).Where(c => !c.DeleteWhenLeftPublished);
             break;
         case ConnectorCriteria.DraftsAndDeleted:
             // Drafted item, get Latest (but exclude deleted)
             query = query.ForVersion(VersionOptions.Latest);
             break;
     }
     return query;
 }
开发者ID:akhurst,项目名称:ricealumni,代码行数:19,代码来源:MechanicsService.cs

示例2: DeleteConnector

        public int DeleteConnector(IContent left, IContent content, bool ignorePermissions = false, bool deleteInverseIfPossible = true, bool definitelyDelete = false)
        {
            var count = 0;
            var connector = content.As<ConnectorPart>();
            if (connector == null) return count;
            var connectorPart = connector.TypePartDefinition;
            if (connectorPart != null)
            {
                // Security check
                if (!ignorePermissions)
                {
                    if (!Services.Authorizer.Authorize(Permissions.DeleteContent, content, T("Could not delete connector")))
                    {
                        return count;
                    }
                }

                if (connector.LeftContentItemId != left.Id)
                {
                    throw new OrchardException(T("Attempted to delete connector from wrong join"));
                }
                
                count++;

                // Versioning. If we delete the connector immediately from a draft then it'll also disappear from the published version.
                // Can't delete connectors from old versions.
                if (left.ContentItem.VersionRecord != null ) {
                    if (left.IsPublished() || definitelyDelete)
                    {
                        // Do a proper remove
                        Services.ContentManager.Remove(content.ContentItem);

                        // TODO: Events to hook into CRUD operations on connectors (so we could delete other related things for example)
                        // TODO: Actually this as well as Create inverse should be done in content handler so we can hook into all normal
                        // content events...?
                        // Check for existing inverse Connector
                        // Note: We don't check permissions on inverse connector, if they can delete one way they have to be able to delete the other.
                        if (deleteInverseIfPossible && connector.InverseConnector != null) {
                            Services.ContentManager.Remove(connector.InverseConnector.ContentItem);
                            count++;
                        }
                    }
                    else {
                        // Flag to delete when published
                        connector.DeleteWhenLeftPublished = true;
                    }
                }
            }
            return count;
        }
开发者ID:akhurst,项目名称:ricealumni,代码行数:50,代码来源:MechanicsService.cs


注:本文中的IContent.IsPublished方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。