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


C# IContent.Parent方法代码示例

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


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

示例1: AddParentForumCaches

        private List<string> AddParentForumCaches(IContent item, List<string> cacheList)
        {
            var parent = item.Parent();

            if (parent != null)
            {
                if (parent.ContentTypeId == forumContentTypeId || parent.ContentTypeId == postContentTypeId)
                {
                    var cache = string.Format("simpilyforum_{0}", parent.Id);
                    if (!cacheList.Contains(cache))
                        cacheList.Add(cache);

                    cacheList = AddParentForumCaches(parent, cacheList);
                }
            }

            return cacheList;
        }
开发者ID:AzarinSergey,项目名称:project-site,代码行数:18,代码来源:SimpilyForumCache.cs

示例2: GetContentPath

        private string GetContentPath(IContent content)
        {
            // works out the path for our content
            string path = "";

            path = helpers.FileHelper.CleanFileName(content.Name);

            if (content.ParentId != -1)
            {
                path = String.Format("{0}\\{1}", GetContentPath(content.Parent()), path);
            }
            
            return path; 
        }
开发者ID:pbevis,项目名称:jumoo.usync,代码行数:14,代码来源:ContentExporter.cs

示例3: ExportContent

        public XElement ExportContent(IContent content)
        {
            LogHelper.Info(typeof(ContentExporter), String.Format("Exporting content {0}", FileHelper.CleanFileName(content.Name)));

            var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : FileHelper.CleanFileName(content.ContentType.Alias);

            // XElement xml = new XElement(nodeName);

            XElement xml = uSyncXmlHelper.ExportContentBase(nodeName, content); 
                        
            // core content item properties 
            xml.Add(new XAttribute("parentGUID", content.Level > 1 ? content.Parent().Key : new Guid("00000000-0000-0000-0000-000000000000")));
            xml.Add(new XAttribute("nodeTypeAlias", content.ContentType.Alias));
            xml.Add(new XAttribute("templateAlias", content.Template == null ? "" : content.Template.Alias));

            xml.Add(new XAttribute("sortOrder", content.SortOrder));
            xml.Add(new XAttribute("published", content.Published));

            return xml; 
        }
开发者ID:pbevis,项目名称:jumoo.usync,代码行数:20,代码来源:ContentExporter.cs

示例4: SearchAncestorForProperty

 private object SearchAncestorForProperty(IContent document, string alias)
 {
     if (document.Properties.Any(n => n.Alias == alias))
         return document.Properties[alias].Value;
     else
         if (document.Level > 1)
         return SearchAncestorForProperty(document.Parent(), alias);
     else
         return null;
 }
开发者ID:MindfireTechnology,项目名称:UmbracoDBSync,代码行数:10,代码来源:OneWayDataSync.cs

示例5: UnVersion

        public void UnVersion(IContent content)
        {
            var configEntries = new List<UnVersionConfigEntry>();

            if (_config.ConfigEntries.ContainsKey(content.ContentType.Alias))
                configEntries.AddRange(_config.ConfigEntries[content.ContentType.Alias]);

            if (_config.ConfigEntries.ContainsKey("$_ALL"))
                configEntries.AddRange(_config.ConfigEntries["$_ALL"]);

            if (configEntries.Count <= 0)
            {
                if (Logger.IsDebugEnabled)
                    Logger.Debug("No unversion configuration found for type " + content.ContentType.Alias);

                return;
            }

            foreach (var configEntry in configEntries)
            {
                var isValid = true;

                if (!String.IsNullOrEmpty(configEntry.RootXPath))
                {
                    if (content.Level > 1 && content.Parent() != null)
                    {
                        var ids = GetNodeIdsFromXpath(configEntry.RootXPath);
                        isValid = ids.Contains(content.ParentId);
                    }
                }

                if (!isValid)
                    continue;

                using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[ "umbracoDbDSN" ].ConnectionString))
                {
                    connection.Open();

                    var vesionsToKeep = VersionsToKeep( content.Id, configEntry, connection );
                    var versionsToKeepString = string.Join( ",", vesionsToKeep );

                    if (Logger.IsDebugEnabled)
                        Logger.Debug("Keeping versions " + versionsToKeepString);

                    var sqlStrings = new List<string> {
                        string.Format(@"
                                    DELETE
                                    FROM	cmsPreviewXml
                                    WHERE	nodeId = {0} AND versionId NOT IN ({1})",
                        content.Id,
                        versionsToKeepString),

                        string.Format(@"
                                    DELETE
                                    FROM	cmsPropertyData
                                    WHERE	contentNodeId = {0} AND versionId  NOT IN ({1})",
                        content.Id,
                        versionsToKeepString),

                        string.Format(@"
                                    DELETE
                                    FROM	cmsContentVersion
                                    WHERE	contentId = {0} AND versionId  NOT IN ({1})",
                        content.Id,
                        versionsToKeepString),

                        string.Format(@"
                                    DELETE
                                    FROM	cmsDocument
                                    WHERE	nodeId = {0} AND versionId  NOT IN ({1})",
                        content.Id,
                        versionsToKeepString)
                    };

                    foreach (var sqlString in sqlStrings)
                    {
                        ExecuteSql(sqlString, connection);
                    }
                }
            }
        }
开发者ID:minirobbo,项目名称:UnVersion,代码行数:81,代码来源:UnVersionService.cs

示例6: SerialiseContent

        /// <summary>
        /// Serialize IContent to XElement and adds dependent nodes 
        /// </summary>
        /// <param name="content">Umbraco IContent object</param>
        /// <param name="dependantNodes">this function will add dependent nodes to this collection</param>
        /// <returns>returns serialized version of IContent as XElement</returns>
        public XElement SerialiseContent(IContent content, Dictionary<int, ObjectTypes> dependantNodes = null)
        {
            dependantNodes = dependantNodes ?? new Dictionary<int, ObjectTypes>();

            var nodeName = content.ContentType.Alias.ToSafeAliasWithForcingCheck();

            var currentContent = new XElement(nodeName,
                new XAttribute("nodeName", content.Name),
                new XAttribute("nodeType", content.ContentType.Id),
                new XAttribute("creatorName", content.GetCreatorProfile().Name),
                new XAttribute("writerName", content.GetWriterProfile().Name),
                new XAttribute("writerID", content.WriterId),
                new XAttribute("templateID", content.Template == null ? "0" : content.Template.Id.ToString(CultureInfo.InvariantCulture)),
                new XAttribute("nodeTypeAlias", content.ContentType.Alias),
                new XAttribute("id", content.Id),
                new XAttribute("parentID", content.Level > 1 ? content.ParentId : -1),
                new XAttribute("level", content.Level),
                new XAttribute("creatorID", content.CreatorId),
                new XAttribute("sortOrder", content.SortOrder),
                new XAttribute("createDate", content.CreateDate.ToString("s")),
                new XAttribute("updateDate", content.UpdateDate.ToString("s")),
                new XAttribute("path", content.Path),
                new XAttribute("isDoc", string.Empty),
                new XAttribute("releaseDate", content.ReleaseDate != null ? content.ReleaseDate.Value.ToString("s") : DateTime.MinValue.ToString("s")),
                new XAttribute("expireDate", content.ExpireDate != null ? content.ExpireDate.Value.ToString("s") : DateTime.MinValue.ToString("s")),
                new XAttribute("parentGuid", content.Level > 1 ? content.Parent().Key.ToString() : string.Empty),
                new XAttribute("guid", content.Key),
                new XAttribute("objectType", ObjectTypes.Document),
                new XAttribute("published", content.Published));

            var propertyTypes = content.PropertyTypes.ToArray();
            var count = 0;

            foreach (var property in content.Properties)
            {
                var tag = property.ToXml();
                var propertyType = propertyTypes.ElementAt(count);
                tag.Add(new XAttribute("dataTypeGuid", propertyType.DataTypeId));
                tag.Add(new XAttribute("dataTypeName", Services.DataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId).Name));

                var guid = propertyTypes.ElementAt(count).DataTypeId;

                // TODO for v6
                if (guid == new Guid(Constants.UploadDataTypeGuid) && property.Value != null)
                {
                    var umbracoFile = property.Value.ToString();
                    tag.Add(
                        new XAttribute("umbracoFile", umbracoFile),
                        new XAttribute("fileName", umbracoFile.Split('/').Last()),
                        new XAttribute("objectType", ObjectTypes.File));
                }
                else if (SpecialDataTypes.ContainsKey(guid))
                {
                    DataTypeConverterExport(property, tag, dependantNodes, SpecialDataTypes[guid]);
                }

                currentContent.Add(tag);
                count++;
            }

            return currentContent;
        }
开发者ID:EnjoyDigital,项目名称:Conveyor,代码行数:68,代码来源:BaseContentManagement.cs

示例7: RecursivelyGetParentsDomains

        private List<string> RecursivelyGetParentsDomains(List<string> domains, IContent content)
        {
            //Termination case
            if(content == null)
            {
                return domains;
            }

            domains.AddRange(ApplicationContext.Current.Services.DomainService.GetAssignedDomains(content.Id, false).Select(x => x.DomainName));

            domains = RecursivelyGetParentsDomains(domains, content.Parent());

            return domains;
        }
开发者ID:scyllagroup,项目名称:UmbracoFlare,代码行数:14,代码来源:UmbracoFlareDomainManager.cs


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