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


C# IPublishedContent.GetPropertyValue方法代码示例

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


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

示例1: 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

示例2: 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

示例3: MapProjectToSimpleDataIndexItem

        public SimpleDataSet MapProjectToSimpleDataIndexItem(IPublishedContent project, SimpleDataSet simpleDataSet, string indexType,
            int karma, IEnumerable<WikiFile> files, int downloads, IEnumerable<string> compatVersions)
        {
            simpleDataSet.NodeDefinition.NodeId = project.Id;
            simpleDataSet.NodeDefinition.Type = indexType;

            var desciption = project.GetPropertyValue<string>("description");
            if (!string.IsNullOrEmpty(desciption))
            {
                simpleDataSet.RowData.Add("body", umbraco.library.StripHtml(desciption));
            }
            simpleDataSet.RowData.Add("nodeName", project.Name);
            simpleDataSet.RowData.Add("updateDate", project.UpdateDate.ToString("yyyy-MM-dd HH:mm:ss"));
            simpleDataSet.RowData.Add("createDate", project.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"));
            simpleDataSet.RowData.Add("nodeTypeAlias", "project");
            simpleDataSet.RowData.Add("url", project.Url );
            simpleDataSet.RowData.Add("uniqueId", project.GetPropertyValue<string>("packageGuid"));
            simpleDataSet.RowData.Add("worksOnUaaS", project.GetPropertyValue<string>("worksOnUaaS"));

            var imageFile = string.Empty;
            if (project.HasValue("defaultScreenshotPath"))
            {
                imageFile = project.GetPropertyValue<string>("defaultScreenshotPath");
            }
            if(string.IsNullOrWhiteSpace(imageFile))
            {
                var image = files.FirstOrDefault(x => x.FileType == "screenshot");
                if (image != null)
                    imageFile = image.Path;
            }
            //Clean up version data before its included in the index
            int o;
            var version = project.GetProperty("compatibleVersions").Value;
            var versions = version.ToString().ToLower()
                            .Replace("nan", "")
                            .Replace("saved", "")
                            .Replace("v", "")
                            .Trim(',').Split(',')
                            .Where(x => int.TryParse(x, out o))
                            .Select(x => (decimal.Parse(x.PadRight(3, '0') ) / 100));

            //popularity for sorting number = downloads + karma * 100;
            var pop = downloads + (karma * 100);

            simpleDataSet.RowData.Add("popularity", pop.ToString());
            simpleDataSet.RowData.Add("karma", karma.ToString());
            simpleDataSet.RowData.Add("downloads", downloads.ToString());
            simpleDataSet.RowData.Add("image", imageFile);

            //now we need to add the versions and compat versions
            // first, this is the versions that the project has files tagged against
            simpleDataSet.RowData.Add("versions", string.Join(",", versions));

            //then we index the versions that the project has actually been flagged as compatible against
            simpleDataSet.RowData.Add("compatVersions", string.Join(",", compatVersions));

            return simpleDataSet;
        }
开发者ID:larrynPL,项目名称:OurUmbraco,代码行数:58,代码来源:ProjectNodeIndexDataService.cs

示例4: item

        /// <summary>
        /// Creates an Item with a publishedContent item in order to properly recurse and return the value.
        /// </summary>
        /// <param name="publishedContent"></param>
        /// <param name="elements"></param>
        /// <param name="attributes"></param>
        /// <remarks>
        /// THIS ENTIRE CLASS WILL BECOME LEGACY, THE FIELD RENDERING NEEDS TO BE REPLACES SO THAT IS WHY THIS
        /// CTOR IS INTERNAL.
        /// </remarks>
        internal item(IPublishedContent publishedContent, IDictionary elements, IDictionary attributes)
        {
            _fieldName = helper.FindAttribute(attributes, "field");

            if (_fieldName.StartsWith("#"))
            {
                _fieldContent = library.GetDictionaryItem(_fieldName.Substring(1, _fieldName.Length - 1));
            }
            else
            {
                // Loop through XML children we need to find the fields recursive
                if (helper.FindAttribute(attributes, "recursive") == "true")
                {
                    if (publishedContent == null)
                    {
                        var recursiveVal = GetRecursiveValueLegacy(elements);
                        _fieldContent = recursiveVal.IsNullOrWhiteSpace() ? _fieldContent : recursiveVal;
                    }
                    else
                    {
					    var pval = publishedContent.GetPropertyValue(_fieldName, true);
					    var rval = pval == null ? string.Empty : pval.ToString();
					    _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
                    }
                }
                else
                {
                    //check for published content and get its value using that
                    if (publishedContent != null)
                    {
                        var pval = publishedContent.GetPropertyValue(_fieldName);
                        var rval = pval == null ? string.Empty : pval.ToString();
                        _fieldContent = rval.IsNullOrWhiteSpace() ? _fieldContent : rval;
                    }
                    else if (elements[_fieldName] != null && string.IsNullOrEmpty(elements[_fieldName].ToString()) == false)
                    {                        
                        //get the vaue the legacy way (this will not parse locallinks, etc... since that is handled with ipublishedcontent)
                        _fieldContent = elements[_fieldName].ToString().Trim();                           
                    }

                    //now we check if the value is still empty and if so we'll check useIfEmpty
                    if (string.IsNullOrEmpty(_fieldContent))
                    {
                        if (string.IsNullOrEmpty(helper.FindAttribute(attributes, "useIfEmpty")) == false)
                        {
                            if (elements[helper.FindAttribute(attributes, "useIfEmpty")] != null && string.IsNullOrEmpty(elements[helper.FindAttribute(attributes, "useIfEmpty")].ToString()) == false)
                            {
                                _fieldContent = elements[helper.FindAttribute(attributes, "useIfEmpty")].ToString().Trim();
                            }
                        }
                    }                    

                }
            }

            ParseItem(attributes);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:67,代码来源:item.cs

示例5: MapCategory

        /// <summary>
        /// Maps a category, cached per request
        /// </summary>
        /// <param name="model"></param>
        /// <param name="getSubAndParentCats"></param>
        /// <returns></returns>
        public static Category MapCategory(IPublishedContent model, bool getSubAndParentCats = false)
        {

            if (model != null)
            {
                var key = string.Format("umb-cat{0}-{1}", model.Id, getSubAndParentCats);
                if (!HttpContext.Current.Items.Contains(key))
                {

                    var pageModel = new Category(model);
                    pageModel.Description = model.GetPropertyValue<string>("description");
                    pageModel.Image = AppHelpers.GetMediaUrlFromProperty(model, "categoryImage");
                    pageModel.LockCategory = model.GetPropertyValue<bool>("lockCategory");
                    pageModel.ModerateAllTopicsInThisCategory = model.GetPropertyValue<bool>("moderateAllTopicsInThisCategory");
                    pageModel.ModerateAllPostsInThisCategory = model.GetPropertyValue<bool>("moderateAllPostsInThisCategory");
                    pageModel.SubCategories = new List<Category>();
                    pageModel.ParentCategories = new List<Category>();

                    // If this node has common properties then populate them
                    // I.e. SEO & Umbraco Properties
                    DialogueMapper.PopulateCommonUmbracoProperties(pageModel, model);

                    // Only get subcategories if the user has requested it
                    if (getSubAndParentCats)
                    {
                        var subCategories = model.Children.ToList();
                        if (model.Children.Any())
                        {
                            foreach (var publishedContent in subCategories)
                            {
                                pageModel.SubCategories.Add(MapCategory(publishedContent, true));
                            }
                        }

                        var path = model.Path;
                        if (!string.IsNullOrEmpty(path))
                        {
                            var catIds = path.Trim().Split(',').Select(x => Convert.ToInt32(x)).ToList();
                            catIds.Remove(model.Id);
                            var allNodes =
                                AppHelpers.UmbHelper()
                                    .TypedContent(catIds)
                                    .Where(x => x != null && x.DocumentTypeAlias == AppConstants.DocTypeForumCategory);
                            foreach (var cat in allNodes)
                            {
                                pageModel.ParentCategories.Add(MapCategory(cat));
                            }
                        }
                    }

                    HttpContext.Current.Items.Add(key, pageModel);
                }

                return HttpContext.Current.Items[key] as Category;
            }
            return null;
        }
开发者ID:ryan-buckman,项目名称:Dialogue,代码行数:63,代码来源:CategoryMapper.cs

示例6: MainContent

 public static string MainContent(IPublishedContent content)
 {
     var bodyText = content.GetPropertyValue<string>(AppConstants.PropBodyText);
     if (string.IsNullOrEmpty(bodyText))
     {
         // Trying mainContent
         bodyText = content.GetPropertyValue<string>("mainContent");
     }
     return bodyText;
 }
开发者ID:ryan-buckman,项目名称:Dialogue,代码行数:10,代码来源:DialogueMapper.cs

示例7: GetListing

        /// <summary>
        /// get listing
        /// </summary>
        /// <param name="content"></param>
        /// <param name="optimized">if set performs less DB interactions to increase speed.</param>
        /// <param name="projectKarma"></param>
        /// <returns></returns>
        public IListingItem GetListing(IPublishedContent content, bool optimized = false, int projectKarma = -1)
        {
            if (content != null)
            {
                var listingItem = new ListingItem.ListingItem(
                    p => GetProjectDownloadCount(p),
                    p => projectKarma < 0 ? GetProjectKarma(p) : projectKarma
                    );

                listingItem.Id = content.Id;
                listingItem.NiceUrl = library.NiceUrl(listingItem.Id);
                listingItem.Name = content.Name;
                listingItem.Description = content.GetPropertyValue<string>("description", "");
                listingItem.CurrentVersion = content.GetPropertyValue<string>("version", "");
                listingItem.CurrentReleaseFile = content.GetPropertyValue<string>("file", "");
                listingItem.DefaultScreenshot = content.GetPropertyValue<string>("defaultScreenshotPath", "");
                listingItem.DevelopmentStatus = content.GetPropertyValue<string>("status", "");
                listingItem.ListingType = content.GetPropertyAsListingType("listingType");
                listingItem.GACode = content.GetPropertyValue<string>("gaCode", "");
                listingItem.CategoryId = content.GetPropertyValue<int>("category");
                listingItem.Stable = content.GetPropertyValue<bool>("stable");
                listingItem.Live = content.GetPropertyValue<bool>("projectLive");
                listingItem.LicenseName = content.GetPropertyValue<string>("licenseName", "");
                listingItem.LicenseUrl = content.GetPropertyValue<string>("licenseUrl", "");
                listingItem.ProjectUrl = content.GetPropertyValue<string>("websiteUrl", "");
                listingItem.SupportUrl = content.GetPropertyValue<string>("supportUrl", "");
                listingItem.SourceCodeUrl = content.GetPropertyValue<string>("sourceUrl", "");
                listingItem.DemonstrationUrl = content.GetPropertyValue<string>("demoUrl", "");
                listingItem.OpenForCollab = content.GetPropertyValue<bool>("openForCollab", false);
                listingItem.NotAPackage = content.GetPropertyValue<bool>("notAPackage", false);
                listingItem.ProjectGuid = new Guid(content.GetPropertyValue<string>("packageGuid"));
                listingItem.Approved = content.GetPropertyValue<bool>("approved", false);
                listingItem.UmbracoVerionsSupported = content.GetPropertyValue<string>("compatibleVersions", "").Split(';');
                listingItem.NETVersionsSupported = (content.GetPropertyValue<string>("dotNetVersion", "") != null) ? content.GetPropertyValue<string>("dotNetVersion", "").Split(';') : "".Split(';');
                listingItem.TrustLevelSupported = content.GetPropertyAsTrustLevel("trustLevelSupported");
                listingItem.TermsAgreementDate = content.GetPropertyValue<DateTime>("termsAgreementDate");
                listingItem.CreateDate = content.CreateDate;
                listingItem.VendorId = content.GetPropertyValue<int>("owner");
                listingItem.Logo = content.GetPropertyValue<string>("logo", "");
                listingItem.LicenseKey = content.GetPropertyValue<string>("licenseKey", "");

                //this section was created to speed up loading operations and cut down on the number of database interactions
                if (optimized == false)
                {
                    listingItem.DocumentationFile = GetMediaForProjectByType(content.Id, FileType.docs);
                    listingItem.ScreenShots = GetMediaForProjectByType(content.Id, FileType.screenshot);
                    listingItem.PackageFile = GetMediaForProjectByType(content.Id, FileType.package);
                    listingItem.HotFixes = GetMediaForProjectByType(content.Id, FileType.hotfix);
                    listingItem.SourceFile = GetMediaForProjectByType(content.Id, FileType.source);
                }

                return listingItem;
            }
            throw new NullReferenceException("Content is Null");
        }
开发者ID:larrynPL,项目名称:OurUmbraco,代码行数:62,代码来源:NodeListingProvider.cs

示例8: GetDate

        // Get datetime from IPublishedContent
        public static DateTime GetDate( this UmbracoHelper umbracoHelper, IPublishedContent publishedContent )
        {
            var listDate = Convert.ToDateTime(publishedContent.GetPropertyValue("listDate"));
            var pageDate = Convert.ToDateTime(publishedContent.GetPropertyValue("pageDate"));

            if(listDate < DateTime.MinValue){
                return listDate;
            } else {
                return pageDate;
            }
        }
开发者ID:NathalieLarsson,项目名称:uMirror_Boilerplate,代码行数:12,代码来源:listHelper.cs

示例9: GetFileUrl

        /// <summary>
        /// Method for getting a file url
        /// </summary>
        /// <param name="content">IPublishedContent with file property</param>
        /// <param name="filePropertyAlias">Property alias</param>
        /// <returns>string</returns>
        public static string GetFileUrl(IPublishedContent content, string filePropertyAlias)
        {
            if (!string.IsNullOrEmpty(content.GetPropertyValue<string>(filePropertyAlias)))
            {
                var file =
                    ApplicationContext.Current.Services.MediaService.GetById(content.GetPropertyValue<int>(filePropertyAlias));

                return file.GetValue<string>("umbracoFile");
            }

            return string.Empty;
        }
开发者ID:pjengaard,项目名称:lilleGrundetDk,代码行数:18,代码来源:MediaMapper.cs

示例10: GetFromContent

 public static SearchModel GetFromContent(IPublishedContent a)
 {
     return new SearchModel
     {
         Id = a.Id,
         Name = a.Name,
         Teaser = a.GetPropertyValue<string>("subheader"),
         Url = a.Url,
         Created = a.CreateDate,
         Updated = a.UpdateDate,
         HideInNavigation = a.GetPropertyValue<bool>("umbracoNaviHide"),
     };
 }
开发者ID:rpjengaard,项目名称:AngularApiTalk,代码行数:13,代码来源:SearchModel.cs

示例11: NewViewModel

 public NewViewModel(IPublishedContent content) : base(content)
 {
     var newItem = new NewItem
     {
         Title = content.GetPropertyValue<string>("title", string.Empty),
         ShortDes = content.GetPropertyValue<string>("shortdes", string.Empty),
         Content = content.GetPropertyValue<string>("content", string.Empty),
         Date = content.GetPropertyValue<DateTime>("date"),
         Image = Helper.GetMediaPicker(content, "image"),
         Link = umbraco.library.NiceUrl(content.Id)
     };
     NewItem = newItem;
 }
开发者ID:dattienmdc,项目名称:dev,代码行数:13,代码来源:NewsViewModel.cs

示例12: Match

 public Match(IPublishedContent content)
     : base(content)
 {
     this.DateAndTime = content.GetPropertyValue<DateTime>("dateAndTime");
     this.AwayGame = content.GetPropertyValue<bool>("awayGame",false);
     var vsc = this.GetMain().OurClub;
     var opponent = new Club(this.GetHelper().TypedContent(content.GetPropertyValue<int>("opponent")));
     var opponentNr = content.GetPropertyValue<int>("opponentTeamNumber") ;
     this.HomeClub = this.AwayGame ? opponent : vsc;
     this.HomeTeamNumber = this.AwayGame ? opponentNr : 3;
     this.AwayClub = this.AwayGame ? vsc : opponent;
     this.AwayTeamNumber = this.AwayGame ? 3 : opponentNr;
 }
开发者ID:voordes,项目名称:MyVSC,代码行数:13,代码来源:Match.cs

示例13: isActive

        // check if the current node should be set as active.
        public static bool isActive(IPublishedContent node, IPublishedContent currentPage )
        {
            if (currentPage.Path.Split(',').Last().Equals(node.Id.ToString()))
            {
                return true;
            }

            if (currentPage.DocumentTypeAlias == "Homepage" && (node.GetPropertyValue("redirectToUrl") == "/" || node.GetPropertyValue("redirectToPage") == currentPage.Id.ToString()))
            {
                return true;
            }
            return false;
        }
开发者ID:NathalieLarsson,项目名称:uMirror_Boilerplate,代码行数:14,代码来源:navigationHelper.cs

示例14: GetImagesUrls

        /// <summary>
        /// Method for getting multiple image urls
        /// </summary>
        /// <param name="content">IPublishedContent with image property</param>
        /// <param name="imagePropertyAlias">Property alias</param>
        /// <param name="cropUpAlias">CropUp alias (optional)</param>
        /// <returns>Collection of string</returns>
        public static List<string> GetImagesUrls(IPublishedContent content, string imagePropertyAlias, string cropUpAlias = null)
        {
            var imageUrls = new List<string>();

            if (!string.IsNullOrEmpty(content.GetPropertyValue<string>(imagePropertyAlias)))
            {
                foreach (var imageId in content.GetPropertyValue<string>(imagePropertyAlias).Split(','))
                {
                    var image = ApplicationContext.Current.Services.MediaService.GetById(int.Parse(imageId));
                    imageUrls.Add(GetCropUpUrl(image, cropUpAlias));
                }
            }

            return imageUrls;
        }
开发者ID:pjengaard,项目名称:lilleGrundetDk,代码行数:22,代码来源:MediaMapper.cs

示例15: GetFromContent

        public static PortfolioItem GetFromContent(IPublishedContent content)
        {
            if (content == null) return null;

            string[] catArr = content.HasValue("categories") ? content.GetPropertyValue<string>("categories").Split(',') : null;

            return new PortfolioItem
            {
                Headline = content.GetPropertyValue<string>("headline"),
                Tags = "Not implented",
                Image = content.HasValue("overviewImage") ? content.TypedMedia("overviewImage") : null,
                Url = content.Url,
                CategoryClasses = catArr != null ? String.Join(" ", catArr) : ""
            };
        }
开发者ID:pjengaard,项目名称:idebankDk,代码行数:15,代码来源:PortfolioItem.cs


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