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


C# IContent.SetTags方法代码示例

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


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

示例1: FormBulkUpdate

 private IContent FormBulkUpdate(IContent form, BulkUpdateModel model)
 {
     if (model.Tags != null)
     {
         form.SetTags("formTags", model.Tags, true, TAG_GROUP_GLEANER_FORM);
     }
     if (model.Groups != null)
     {
         form.SetValue("associatedGroups", string.Join(",", model.Groups));
     }
     if (model.IsPublic.HasValue)
     {
         form.SetValue("isPublic", model.IsPublic.Value);
     }
     if (model.IsRequired.HasValue)
     {
         form.SetValue("isRequired", model.IsRequired.Value);
     }
     if (model.StartDate.HasValue)
     {
         form.SetValue("startDate", model.StartDate.Value);
     }
     if (model.EndDate.HasValue)
     {
         form.SetValue("endDate", model.EndDate.Value);
     }
     return form;
 }
开发者ID:AzarinSergey,项目名称:project-site,代码行数:28,代码来源:FormService.cs

示例2: FormBulkAdd

 private IContent FormBulkAdd(IContent form, BulkUpdateModel model)
 {
     if (model.Tags != null)
     {
         form.SetTags("formTags", model.Tags, false, TAG_GROUP_GLEANER_FORM);
     }
     if (model.Groups != null)
     {
         var currentValue = form.GetValue<string>("associatedGroups").ToDelimitedList().Select(Int32.Parse);
         form.SetValue("associatedGroups", string.Join(",", currentValue.Union(model.Groups)));
     }
     return form;
 }
开发者ID:AzarinSergey,项目名称:project-site,代码行数:13,代码来源:FormService.cs

示例3: AddOrUpdateContent

        private void AddOrUpdateContent(IContent content, MetaWeblogPost post, IUser user, bool publish)
        {
            content.Name = post.Title;
            content.SetValue("author", user.Name);
            if (content.HasProperty("richText"))
            {
                content.SetValue("richText", post.Content);
            }
            if (!post.Slug.IsNullOrWhiteSpace())
            {
                content.SetValue("umbracoUrlName", post.Slug);
            }
            if (!post.Excerpt.IsNullOrWhiteSpace())
            {
                content.SetValue("excerpt", post.Excerpt);
            }
            if (post.AllowComments == 1)
            {
                content.SetValue("enableComments", 1);
            }
            else if (post.AllowComments == 2)
            {
                content.SetValue("enableComments", 0);
            }
            content.SetTags("categories", post.Categories, true, "ArticulateCategories");
            var tags = post.Tags.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray();
            content.SetTags("tags", tags, true, "ArticulateTags");

            if (publish)
            {
                if (post.CreateDate != DateTime.MinValue)
                {
                    content.SetValue("publishedDate", post.CreateDate);
                }

                _applicationContext.Services.ContentService.SaveAndPublishWithStatus(content, user.Id);
            }
            else
            {
                _applicationContext.Services.ContentService.Save(content, user.Id);
            }
        }
开发者ID:Jeavon,项目名称:Articulate,代码行数:42,代码来源:MetaWeblogHandler.cs

示例4: AddOrUpdateContent

        private void AddOrUpdateContent(IContent content, MetaWeblogPost post, IUser user, bool publish, bool extractFirstImageAsProperty)
        {
            content.Name = post.Title;
            content.SetValue("author", user.Name);
            if (content.HasProperty("richText"))
            {
                var firstImage = "";

                //we need to replace all absolute image paths with relative ones
                var contentToSave = _mediaSrc.Replace(post.Content, match =>
                {
                    if (match.Groups.Count == 2)
                    {
                        var imageSrc = match.Groups[1].Value.EnsureStartsWith('/');
                        if (firstImage.IsNullOrWhiteSpace())
                        {
                            firstImage = imageSrc;
                        }
                        return " src=\"" + imageSrc + "\"";
                    }
                    return null;
                });

                var imagesProcessed = 0;

                //now replace all absolute anchor paths with relative ones
                contentToSave = _mediaHref.Replace(contentToSave, match =>
                {
                    if (match.Groups.Count == 2)
                    {
                        var href = " href=\"" +
                               match.Groups[1].Value.EnsureStartsWith('/') +
                               "\" class=\"a-image-" + imagesProcessed + "\" ";

                        imagesProcessed++;

                        return href;
                    }
                    return null;
                });

                content.SetValue("richText", contentToSave);

                if (extractFirstImageAsProperty
                    && content.HasProperty("postImage")
                    && !firstImage.IsNullOrWhiteSpace())
                {
                    content.SetValue("postImage", firstImage);
                    //content.SetValue("postImage", JsonConvert.SerializeObject(JObject.FromObject(new
                    //{
                    //    src = firstImage
                    //})));
                }
            }

            if (!post.Slug.IsNullOrWhiteSpace())
            {
                content.SetValue("umbracoUrlName", post.Slug);
            }
            if (!post.Excerpt.IsNullOrWhiteSpace())
            {
                content.SetValue("excerpt", post.Excerpt);
            }

            if (post.AllowComments == 1)
            {
                content.SetValue("enableComments", 1);
            }
            else if (post.AllowComments == 2)
            {
                content.SetValue("enableComments", 0);
            }

            content.SetTags("categories", post.Categories, true, "ArticulateCategories");
            var tags = post.Tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToArray();
            content.SetTags("tags", tags, true, "ArticulateTags");

            if (publish)
            {
                if (post.CreateDate != DateTime.MinValue)
                {
                    content.SetValue("publishedDate", post.CreateDate);
                }

                _applicationContext.Services.ContentService.SaveAndPublishWithStatus(content, user.Id);
            }
            else
            {
                _applicationContext.Services.ContentService.Save(content, user.Id);
            }
        }
开发者ID:simonech,项目名称:Articulate,代码行数:91,代码来源:MetaWeblogHandler.cs


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