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


C# IPublishedContent类代码示例

本文整理汇总了C#中IPublishedContent的典型用法代码示例。如果您正苦于以下问题:C# IPublishedContent类的具体用法?C# IPublishedContent怎么用?C# IPublishedContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetBlogPostPageModel

        /// <summary>
        /// Gets the model for the blog post page
        /// </summary>
        /// <param name="currentPage">The current page</param>
        /// <param name="currentMember">The current member</param>
        /// <returns>The page model</returns>
        public BlogPostViewModel GetBlogPostPageModel(IPublishedContent currentPage, IMember currentMember)
        {
            var model = GetPageModel<BlogPostViewModel>(currentPage, currentMember);
            model.ImageUrl = GravatarHelper.CreateGravatarUrl(model.Author.Email, 200, string.Empty, null, null, null);

            return model;
        }
开发者ID:robertpurcell,项目名称:UmbracoSandbox,代码行数:13,代码来源:BlogPostPageHandler.cs

示例2: FromIPublishedContent

		/// <summary>
		/// Converts an IPublishedContent instance to SimpleContent.
		/// </summary>
		/// <param name="content">The IPublishedContent instance you wish to convert.</param>
		/// <param name="recurseChildren">Whether to include the children in the SimpleContent instance.</param>
		/// <param name="recurseContentTypes">Whether to include the parent content types on each SimpleContent instance.</param>
		/// <param name="recurseTemplates">Whether to include the parent templates on each SimpleContent instance.</param>
		/// <returns>A SimpleContent representation of the specified IPublishedContent</returns>
		public static SimpleContent FromIPublishedContent(IPublishedContent content, bool recurseChildren = true, bool recurseContentTypes = true, bool recurseTemplates = true) {
			if (content == null) return null;

			/*
			 * Using string, object for key/value pairs.
			 * An object is used so that the JavaScriptSerializer will
			 * automatically detect the type and serialize it to the
			 * correct JavaScript type.
			 */
			var properties =
				content.Properties
				       .Where(p => !String.IsNullOrWhiteSpace(p.Value.ToString()))
				       .ToDictionary(prop => prop.Alias, prop => prop.Value);
			
			var result = new SimpleContent() {
				Id = content.Id,
				Name = content.Name,
				Url = content.Url,
				Level = content.Level,
				Properties = properties,
				ContentType = SimpleContentType.FromContentType(content.DocumentTypeId, recurseContentTypes),
				Template = SimpleTemplate.FromTemplate(content.TemplateId, recurseTemplates),
				ChildrenIds = content.Children.Select(x => x.Id).ToList()
			};

			if (recurseChildren) {
				result.Children = FromIPublishedContent(content.Children, true, recurseContentTypes, recurseTemplates);
			}

			return result;
		}
开发者ID:Nicholas-Westby,项目名称:rhythm.umbraco.extensions,代码行数:39,代码来源:SimpleContent.cs

示例3: SetUp

        public void SetUp()
        {
            _archetype = ContentHelpers.Archetype;

            var content = ContentHelpers.FakeContent(123, "Fake Node 1", properties: new Collection<IPublishedProperty>
            {
                new FakePublishedProperty("myArchetypeProperty", _archetype, true)
            });

            _content = new FakeModel(content);
            _propertyDescriptor = TypeDescriptor.GetProperties(_content)["TextString"];

            _context = new FakeDittoValueResolverContext(_content, _propertyDescriptor);

            var mockedPropertyService = new Mock<PropertyValueService>();

            mockedPropertyService.SetupSequence(
                i =>
                    i.Set(It.IsAny<IPublishedContent>(), It.IsAny<CultureInfo>(), It.IsAny<PropertyInfo>(),
                        It.IsAny<object>(), It.IsAny<object>(), It.IsAny<DittoValueResolverContext>()))
                        .Returns(new HtmlString("<p>This is the <strong>summary</strong> text.</p>"))
                        .Returns("Ready to Enroll?")
                        .Returns("{}");

            _sut = new ArchetypeBindingService(mockedPropertyService.Object, new DittoAliasLocator());
        }
开发者ID:Nicholas-Westby,项目名称:Ditto.Resolvers,代码行数:26,代码来源:ArchetypeBindingServiceTests.cs

示例4: ImagePickerImage

 /// <summary>
 /// Initializes a new instance based on the specified <code>content</code>.
 /// </summary>
 /// <param name="content">An instance of <see cref="IPublishedContent"/> representing the selected image.</param>
 protected ImagePickerImage(IPublishedContent content) {
     Image = content;
     Width = content.GetPropertyValue<int>(global::Umbraco.Core.Constants.Conventions.Media.Width);
     Height = content.GetPropertyValue<int>(global::Umbraco.Core.Constants.Conventions.Media.Height);
     Url = content.Url;
     CropUrl = content.GetCropUrl(Width, Height, preferFocalPoint: true, imageCropMode: ImageCropMode.Crop);
 }
开发者ID:skybrud,项目名称:Skybrud.ImagePicker,代码行数:11,代码来源:ImagePickerImage.cs

示例5: GetPostCreatorFullName

        public static string GetPostCreatorFullName(IPublishedContent member, IPublishedContent post)
        {
            string memberFullName = null;

            if (member != null)
            {
                memberFullName = String.Format("{0} {1}", member.GetPropertyValue<String>("arborFirstName"), member.GetPropertyValue<String>("arborLastName")).Trim();

                if (String.IsNullOrEmpty(memberFullName))
                {
                    memberFullName = String.Format("{0} {1}", member.GetPropertyValue<String>("firstName"), member.GetPropertyValue<String>("lastName")).Trim();
                }

                if (String.IsNullOrEmpty(memberFullName))
                {
                    memberFullName = member.Name;
                }
            }

            if (String.IsNullOrEmpty(memberFullName) && (post != null))
            {
                memberFullName = post.CreatorName;
            }

            if (String.IsNullOrEmpty(memberFullName))
            {
                memberFullName = "Not Available";
            }

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

示例6: RenderDocTypeGridEditorItem

        public static HtmlString RenderDocTypeGridEditorItem(this HtmlHelper helper,
            IPublishedContent content,
            string viewPath = "",
            string actionName = "",
            object model = null)
        {
            if (content == null)
                return new HtmlString(string.Empty);

            var controllerName = content.DocumentTypeAlias + "Surface";

            if (!string.IsNullOrWhiteSpace(viewPath))
                viewPath = viewPath.TrimEnd('/') + "/";

            if (string.IsNullOrWhiteSpace(actionName))
                actionName = content.DocumentTypeAlias;

            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            if (umbracoHelper.SurfaceControllerExists(controllerName, actionName, true))
            {
                return helper.Action(actionName, controllerName, new
                {
                    dtgeModel = model ?? content,
                    dtgeViewPath = viewPath
                });
            }

            if (!string.IsNullOrWhiteSpace(viewPath))
                return helper.Partial(viewPath + content.DocumentTypeAlias + ".cshtml", content);

            return helper.Partial(content.DocumentTypeAlias, content);
        }
开发者ID:nvisage-gf,项目名称:umbraco-doc-type-grid-editor,代码行数:32,代码来源:HtmlHelperExtensions.cs

示例7: GetBranch

 private static IEnumerable<Tuple<IPublishedContent, dynamic>> GetBranch(IPublishedContent document)
 {
     IEnumerable<IPublishedContent> children = document.GetPropertyValue<bool>("excludeChildrenFromSiteMap") ?
         Enumerable.Empty<IPublishedContent>() :
         document.Children.Where(x => !x.GetPropertyValue<bool>("excludeFromSiteMap") && x.HasProperty("excludeFromSiteMap")).ToArray();
     return from child in children select Tuple.Create<IPublishedContent, dynamic>(child, GetBranch(child));
 }
开发者ID:AzarinSergey,项目名称:UmbracoE-commerceBadPractic_1,代码行数:7,代码来源:Unico.Etechno.SiteMapHelper.cs

示例8: Init

		public override void Init(IPublishedContent content)
		{
			base.Init(content);
						
			this.Authors = Content.GetPropertyValue<string>("authors");
			
		}
开发者ID:ismailmayat,项目名称:umbraco.examine.linq,代码行数:7,代码来源:AuthorsRepository.cs

示例9: AddCountryToDataSet

        private void AddCountryToDataSet(ResultData resultData, IPublishedContent landkosten, string goalCurrency, String localizedYear)
        {
            var kostenland = new CountryCost(landkosten, goalCurrency);

            for (int i = 1; i <= 20; i++)
            {

                int jaarTakseInGoalCurrency = kostenland.GetYear(i) ?? default(int);

                if (jaarTakseInGoalCurrency > resultData.MaxTakse)
                {
                    resultData.MaxTakse = jaarTakseInGoalCurrency;
                }

                resultData.AddDataPoint(i, jaarTakseInGoalCurrency, localizedYear);
            }

            string stepWidthString = (resultData.MaxTakse / 10).ToString();
            int biggestInt = Convert.ToInt32(stepWidthString[0].ToString()) + 1;
            string nextBigNumberforStep = biggestInt.ToString();

            for (int i = 0; i < stepWidthString.Length - 1; i++)
            {
                nextBigNumberforStep += "0";
            }

            int nextBigNumberForStepInt = Convert.ToInt32(nextBigNumberforStep);
            resultData.StepWidth = nextBigNumberForStepInt;
        }
开发者ID:rubenski,项目名称:pvista,代码行数:29,代码来源:CountryDataController.cs

示例10: CreateModel

        /// <summary>
        /// Creates a strongly-typed model representing a published content.
        /// </summary>
        /// <param name="content">The original published content.</param>
        /// <returns>
        /// The strongly-typed model representing the published content, or the published content
        /// itself it the factory has no model for that content type.
        /// </returns>
        public IPublishedContent CreateModel(IPublishedContent content)
        {
            // HACK: [LK:2014-12-04] It appears that when a Save & Publish is performed in the back-office, the model-factory's `CreateModel` is called.
            // This can cause a null-reference exception in specific cases, as the `UmbracoContext.PublishedContentRequest` might be null.
            // Ref: https://github.com/leekelleher/umbraco-ditto/issues/14
            if (UmbracoContext.Current == null || UmbracoContext.Current.PublishedContentRequest == null)
            {
                return content;
            }

            if (this.converterCache == null)
            {
                return content;
            }

            var contentTypeAlias = content.DocumentTypeAlias;
            Func<IPublishedContent, IPublishedContent> converter;

            if (!this.converterCache.TryGetValue(contentTypeAlias, out converter))
            {
                return content;
            }

            return converter(content);
        }
开发者ID:robertjf,项目名称:umbraco-ditto,代码行数:33,代码来源:DittoPublishedContentModelFactory.cs

示例11: BuildLinkTier

        /// <summary>
        /// Builds a <see cref="ILinkTier"/>
        /// </summary>
        /// <param name="tierItem">The <see cref="IPublishedContent"/> "tier" item (the parent tier)</param>
        /// <param name="current">The current <see cref="IPublishedContent"/> in the recursion</param>
        /// <param name="excludeDocumentTypes">A collection of document type aliases to exclude</param>
        /// <param name="tierLevel">The starting "tier" level. Note this is the Umbraco node level</param>
        /// <param name="maxLevel">The max "tier" level. Note this is the Umbraco node level</param>
        /// <param name="includeContentWithoutTemplate">True or false indicating whether or not to include content that does not have an associated template</param>
        /// <returns>the <see cref="ILinkTier"/></returns>
        public ILinkTier BuildLinkTier(IPublishedContent tierItem, IPublishedContent current, string[] excludeDocumentTypes = null, int tierLevel = 0, int maxLevel = 0, bool includeContentWithoutTemplate = false)
        {
            var active = current.Path.Contains(tierItem.Id.ToString(CultureInfo.InvariantCulture));

            if (current.Level == tierItem.Level) active = current.Id == tierItem.Id;

            var tier = new LinkTier()
            {
                ContentId = tierItem.Id,
                ContentTypeAlias = tierItem.DocumentTypeAlias,
                Title = tierItem.Name,
                Url = ContentHasTemplate(tierItem) ? tierItem.Url : string.Empty,
                CssClass = active ? "active" : string.Empty
            };

            if (excludeDocumentTypes == null) excludeDocumentTypes = new string[] { };

            if (tierLevel > maxLevel && maxLevel != 0) return tier;

            foreach (var item in tierItem.Children.ToList().Where(x => x.IsVisible() && (ContentHasTemplate(x) || (includeContentWithoutTemplate && x.IsVisible())) && !excludeDocumentTypes.Contains(x.DocumentTypeAlias)))
            {
                var newTier = BuildLinkTier(item, current, excludeDocumentTypes, item.Level, maxLevel);

                if (AddingTier != null)
                {
                    AddingTier.Invoke(this, new AddingLinkTierEventArgs(tier, newTier));    
                }
                                
                tier.Children.Add(newTier);
            }

            return tier;
        }
开发者ID:naepalm,项目名称:Buzz.Hybrid,代码行数:43,代码来源:LinkHelper.cs

示例12: GetImage

        /// <summary>
        /// Maps the image model from the media node
        /// </summary>
        /// <param name="mapper">Umbraco mapper</param>
        /// <param name="media">Media node</param>
        /// <returns>Image model</returns>
        public static object GetImage(IUmbracoMapper mapper, IPublishedContent media)
        {
            var image = GetModel<ImageViewModel>(mapper, media);
            MapImageCrops(media, image);

            return image;
        }
开发者ID:robertpurcell,项目名称:UmbracoSandbox,代码行数:13,代码来源:MediaMapper.cs

示例13: GetImageUrl

 public static string GetImageUrl(this UmbracoContext context, IPublishedContent node, string propertyName)
 {
     var helper = new UmbracoHelper(context);
     var imageId = node.GetPropertyValue<int>(propertyName);
     var typedMedia = helper.TypedMedia(imageId);
     return typedMedia != null ? typedMedia.Url : null;
 }
开发者ID:kenballard,项目名称:NuthinButNet,代码行数:7,代码来源:ImageHelpers.cs

示例14: GetThemePath

 /// <summary>
 /// Gets the path to the currently assigned theme.
 /// </summary>
 /// <param name="model">
 /// The <see cref="IMasterModel"/>.
 /// </param>
 /// <returns>
 /// The <see cref="string"/> representing the path to the starter kit theme folder.
 /// </returns>
 public static string GetThemePath(IPublishedContent model)
 {
     const string Path = "~/App_Plugins/Merchello.Bazaar/Themes/{0}/";
     return model.HasProperty("theme") && model.HasValue("theme") ? 
         string.Format(Path, model.GetPropertyValue<string>("theme")) :
         string.Empty;
 }
开发者ID:drpeck,项目名称:Merchello,代码行数:16,代码来源:PathHelper.cs

示例15: ConvertedNode

            public ConvertedNode(IPublishedContent doc)
            {
                _doc = doc;

                if (doc == null)
                {
                    Id = 0;
                    return;
                }

                template = doc.TemplateId;
                Id = doc.Id;
                Path = doc.Path;
                CreatorName = doc.CreatorName;
                SortOrder = doc.SortOrder;
                UpdateDate = doc.UpdateDate;
                Name = doc.Name;
                NodeTypeAlias = doc.DocumentTypeAlias;
                CreateDate = doc.CreateDate;
                CreatorID = doc.CreatorId;
                Level = doc.Level;
                UrlName = doc.UrlName;
                Version = doc.Version;
                WriterID = doc.WriterId;
                WriterName = doc.WriterName;
            }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:26,代码来源:CompatibilityHelper.cs


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