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


C# IPublishedContent.HasValue方法代码示例

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


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

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

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

示例3: TitleTag

        public static string TitleTag(IPublishedContent currentPage)
        {
            if (currentPage.HasProperty(Up.Mixins.Seo.TitleTag) && currentPage.HasValue(Up.Mixins.Seo.TitleTag)) { return currentPage.GetPropertyValue<string>(Up.Mixins.Seo.TitleTag); }

            if (currentPage.Level > 1) { return currentPage.Name; }

            return Settings.DefaultTitleTag;
        }
开发者ID:Philo,项目名称:gulp-test,代码行数:8,代码来源:SEOHelpers.cs

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

示例5: PopulateCommonUmbracoProperties

 /// <summary>
 /// Common properties to map
 /// </summary>
 /// <param name="modelObject"></param>
 /// <param name="model"></param>
 public static void PopulateCommonUmbracoProperties(MasterModel modelObject, IPublishedContent model)
 {
     modelObject.PageTitle = model.HasValue(AppConstants.PropPageTitle) ? model.GetPropertyValue<string>(AppConstants.PropPageTitle) : model.Name;
     modelObject.MetaDesc = model.GetPropertyValue(AppConstants.PropMetaDesc, library.TruncateString(library.StripHtml(model.GetPropertyValue<string>(AppConstants.PropBodyText, "")), 160, "")).ToString();
     modelObject.NodePath = model.Path.Split(',').Select(x => Convert.ToInt32(x)).ToList();
     modelObject.HideFromNavigation = model.GetPropertyValue<bool>(AppConstants.PropUmbracoNaviHide);
     modelObject.ShowInFooter = model.GetPropertyValue<bool>(AppConstants.PropShowInFooter);
     modelObject.ConversionCode = model.GetPropertyValue<string>(AppConstants.PropConversionCodes);
 }
开发者ID:ryan-buckman,项目名称:Dialogue,代码行数:14,代码来源:DialogueMapper.cs

示例6: OGImage

        public static string OGImage(IPublishedContent currentPage)
        {
            if (currentPage.HasProperty(Up.Mixins.Seo.OgImage) && currentPage.HasValue(Up.Mixins.Seo.OgImage))
            {
                return @"<meta property=""og:image"" content=""" + Settings.BaseUrlWithoutSlash + new UmbracoHelper(UmbracoContext.Current).TypedMedia(currentPage.GetPropertyValue<int>(Up.Mixins.Seo.OgImage)).GetCropUrl(CropSize.OGImage_1200_x_630) + @""">";
            }

            return "";
        }
开发者ID:Philo,项目名称:gulp-test,代码行数:9,代码来源:SEOHelpers.cs

示例7: Map

        public static WebsiteHouse Map(IPublishedContent content)
        {
            var model = new WebsiteHouse
                {
                    HouseNumber = content.GetProperty("husnummer") != null
                            ? content.GetPropertyValue<int>("husnummer")
                            : -1,

                    Residents = WebsiteResidentMapper.MapResidents(content),

                    ResidentsString = content.HasValue("antalPersonerIHusstanden") ? content.GetPropertyValue<string>("antalPersonerIHusstanden") : "",

                    MoveInDate = content.GetProperty("indflytningsdato") != null
                            ? content.GetPropertyValue<DateTime>("indflytningsdato")
                            : DateTime.MinValue
                };

            return model;
        }
开发者ID:pjengaard,项目名称:lilleGrundetDk,代码行数:19,代码来源:WebsiteHouseMapper.cs

示例8: SelfServiceActionPage

        private SelfServiceActionPage(SearchResult result, IPublishedContent content) {

            Id = result.Id;

            if (content == null) {

                string title;
                Title = result.Fields.TryGetValue("title", out title) ? title : result.Fields["nodeName"];

                Categories = new SelfServiceCategory[0];

            } else {

                Title = content.HasValue("title") ? content.GetPropertyValue<string>("title") : content.Name;

                Url = content.Url;

                Categories = content.GetPropertyValue<SelfServiceCategory[]>("skySelfServiceCategories") ?? new SelfServiceCategory[0];

            }
        
        }
开发者ID:skybrud,项目名称:Skybrud.Umbraco.SelfService,代码行数:22,代码来源:SelfServiceActionPage.cs

示例9: GetObjectByNode

        public static CanvasModel GetObjectByNode(IPublishedContent node)
        {
            try
            {
                var model = new CanvasModel();

                if (node.HasProperty("canvas") && node.HasValue("canvas"))
                {

                    string json = node.GetPropertyValue<string>("canvas");

                    model = JsonConvert.DeserializeObject<CanvasModel>(json);

                }

                return model;
            }
            catch (Exception ex)
            {
                Log.Error("Canvas error on GetObjectByNode in Repository.", ex);
                return null;
            }

        }
开发者ID:Vettvangur,项目名称:Canvas,代码行数:24,代码来源:Repository.cs

示例10: ConvertToItem

        private ItemPreview ConvertToItem(IPublishedContent result)
        {
            var item = new ItemPreview();
            item.NodeId = result.Id;
            item.NodeTypeAlias = result.DocumentTypeAlias;
            item.ParentName = result.Parent.Name;
            item.ParentUrl = result.Parent.Url;
            item.Url = result.Url;
            if (result.HasProperty("contentTitle") && result.HasValue("contentTitle"))
            {
                item.Title = result.GetPropertyValue<string>("contentTitle");
            }
            if (result.HasProperty("contentSubtitle") && result.HasValue("contentSubtitle"))
            {
                item.Subtitle = result.GetPropertyValue<string>("contentSubtitle");
            }
            if (result.HasProperty("contentDescription") && result.HasValue("contentDescription"))
            {
                item.Description = result.GetPropertyValue<string>("contentDescription");
            }
            if (result.HasProperty("contentThumbnail") && result.HasValue("contentThumbnail"))
            {
                item.ThumbnailImageUrl = umbracoHelper.TypedMedia(result.GetPropertyValue("contentThumbnail")).Url;
            }
            if (result.HasProperty("contentThumbnailVideo") && result.HasValue("contentThumbnailVideo"))
            {
                item.ThumnailVideoUrl = result.GetPropertyValue<string>("contentThumbnailVideo");
            }
            if (result.HasProperty("contentDate") && result.HasValue("contentDate"))
            {
                item.Date = result.GetPropertyValue<DateTime>("contentDate");
                item.DateFormatted = item.Date.ToString("dd MMMMMMMMM, yyyy", CultureInfo.GetCultureInfoByIetfLanguageTag("pt"));
            }

            return item;
        }
开发者ID:danielribamar,项目名称:mojopin,代码行数:36,代码来源:SearchService.cs

示例11: GetIntValue

    public static int GetIntValue(IPublishedContent node, string propertyName)
    {
        if (node.HasValue(propertyName))
        {
            var property = node.GetProperty(propertyName);
            if (property == null) return 0;

            return Convert.ToInt32(property.Value);
        }

        return 0;
    }
开发者ID:Wolframart,项目名称:wolframart,代码行数:12,代码来源:Tapas.cs

示例12: MemberAvatarPath

        private static string MemberAvatarPath(IPublishedContent member)
        {
            try
            {
                var hasAvatar = member.HasValue("avatar");
                if (hasAvatar)
                {
                    var avatarPath = member.GetPropertyValue("avatar").ToString();
                    var path = HostingEnvironment.MapPath(avatarPath);
                    if (System.IO.File.Exists(path))
                        return path;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error<Utils>("Could not get MemberAvatarPath", ex);
            }

            return string.Empty;
        }
开发者ID:QuangDang212,项目名称:OurUmbraco,代码行数:20,代码来源:library.cs

示例13: MemberAvatarPath

        private static string MemberAvatarPath(IPublishedContent member)
        {
            var hasAvatar = member.HasValue("avatar");
            if (hasAvatar)
            {
                var avatarPath = member.GetPropertyValue("avatar").ToString();
                var path = HostingEnvironment.MapPath(avatarPath);
                if (System.IO.File.Exists(path))
                    return path;
            }

            return string.Empty;
        }
开发者ID:KerwinMa,项目名称:OurUmbraco,代码行数:13,代码来源:library.cs

示例14: GetSelectedUsers

        /// <summary>
        /// Gets selected users list from Multi User Select type field
        /// </summary>
        /// <param name="node"></param>
        /// <param name="propertyAlias"></param>
        /// <returns></returns>
        public static IEnumerable<User> GetSelectedUsers(IPublishedContent node, String propertyAlias)
        {
            List<User> selectedUsers = new List<User>();

            if (node != null && !String.IsNullOrEmpty(propertyAlias) && node.HasProperty(propertyAlias) && node.HasValue(propertyAlias))
            {
                var userIds = node.GetPropertyValue<String>(propertyAlias).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var selectedUserId in userIds)
                {
                    User user = User.GetUser(Int32.Parse(selectedUserId));
                    if (user != null)
                    {
                        selectedUsers.Add(user);
                    }
                }
            }

            return selectedUsers;
        }
开发者ID:pawelgur,项目名称:UmbracoExtensions,代码行数:25,代码来源:UmbracoNodeHelpers.cs

示例15: MapProjectToSimpleDataIndexItem

        public SimpleDataSet MapProjectToSimpleDataIndexItem(IPublishedContent project, SimpleDataSet simpleDataSet, string indexType,
            int projectVotes, WikiFile[] files, int downloads, IEnumerable<string> compatVersions)
        {
            var isLive = project.GetPropertyValue<bool>("projectLive");
            var isApproved = project.GetPropertyValue<bool>("approved");

            var minimumVersionStrict = string.Empty;
            var currentFileId = project.GetPropertyValue<int>("file");
            if (currentFileId > 0)
            {
                var currentFile = files.FirstOrDefault(x => x.Id == currentFileId);
                if (currentFile != null)
                    minimumVersionStrict = currentFile.MinimumVersionStrict;
            }

            simpleDataSet.NodeDefinition.NodeId = project.Id;
            simpleDataSet.NodeDefinition.Type = indexType;

            simpleDataSet.RowData.Add("body", project.GetPropertyValue<string>("description"));
            simpleDataSet.RowData.Add("nodeName", project.Name);
            simpleDataSet.RowData.Add("categoryFolder", project.Parent.Name.ToLowerInvariant().Trim());
            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"));
            simpleDataSet.RowData.Add("minimumVersionStrict", minimumVersionStrict);

            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, the reason we have to do this
            // is due to the way the version data is stored, you can see it in uVersion.config - it's super strange
            // because of the 3 digit nature but when it doesn't end with a '0' it's actually just the major/minor version
            // so we have to do all of this parsing.
            var version = project.GetPropertyValue<string>("compatibleVersions") ?? string.Empty;
            var cleanedVersions = version.ToLower()
                .Replace("nan", "")
                .Replace("saved", "")
                .Replace("v", "")
                .Trim(',')
                .Split(',')
                //it's stored as an int like 721 (for version 7.2.1)
                .Where(x => x.Length <= 3 && x.Length > 0)
                //pad it out to 3 digits
                .Select(x => x.PadRight(3, '0'))
                .Select(x =>
                {
                    int o;
                    if (int.TryParse(x, out o))
                    {
                        //if it ends with '0', that means it's a X.X.X version
                        // if it does not end with '0', that means that the last 2 digits are the
                        // Minor part of the version
                        return x.EndsWith("0")
                            ? string.Format("{0}.{1}.{2}", x[0], x[1], 0)
                            : string.Format("{0}.{1}.{2}", x[0], x.Substring(1), 0);
                    }
                    return null;
                })
                .Where(x => x != null);

            var cleanedCompatVersions = compatVersions.Select(x => x.Replace("nan", "")
                .Replace("saved", "")
                .Replace("nan", "")
                .Replace("v", "")
                .Replace(".x", "")
                .Trim(','));

            //popularity for sorting number = downloads + karma * 100;
            //TODO: Change score so that we take into account:
            // - recently updated
            // - works on latest umbraco versions
            // - works on uaas
            // - has a forum
            // - has source code link
            // - open for collab / has collaborators
            // - download count in a recent timeframe - since old downloads should count for less

            var pop = downloads + (projectVotes * 100);

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

            var packageFiles = files.Count(x => x.FileType == "package");
            simpleDataSet.RowData.Add("packageFiles", packageFiles.ToString());

            simpleDataSet.RowData.Add("projectLive", isLive ? "1" : "0");
//.........这里部分代码省略.........
开发者ID:umbraco,项目名称:OurUmbraco,代码行数:101,代码来源:ProjectNodeIndexDataService.cs


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