當前位置: 首頁>>代碼示例>>C#>>正文


C# Node.GetProperty方法代碼示例

本文整理匯總了C#中umbraco.NodeFactory.Node.GetProperty方法的典型用法代碼示例。如果您正苦於以下問題:C# Node.GetProperty方法的具體用法?C# Node.GetProperty怎麽用?C# Node.GetProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在umbraco.NodeFactory.Node的用法示例。


在下文中一共展示了Node.GetProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetFileUrl

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

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

            return string.Empty;
        }
開發者ID:pjengaard,項目名稱:lilleGrundetDk,代碼行數:18,代碼來源:MediaMapper.cs

示例2: ImportPageContent

        public static void ImportPageContent(int importPageId)
        {
            Node importPage = new Node(importPageId);

            var rawData = APIHelper.GetPageRaw(importPage.GetProperty("gatherContentId").ToString());
            var structure = GetPageContentStructure(rawData);
            var pageContent = DecodeFrom64(structure.page.config);
            var pageStructure = GetPageStructure(pageContent);
            AddPageContent(pageStructure, importPageId);
        }
開發者ID:Philo,項目名稱:gulp-test,代碼行數:10,代碼來源:ImportContent.cs

示例3: GetImagesUrls

        /// <summary>
        /// Method for getting multiple image urls
        /// </summary>
        /// <param name="node">Node 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(Node node, string imagePropertyAlias, string cropUpAlias = null)
        {
            var imageUrls = new List<string>();
            if (!string.IsNullOrEmpty(node.GetProperty<string>(imagePropertyAlias)))
            {
                foreach (var imageId in node.GetProperty<string>(imagePropertyAlias).Split(','))
                {
                    var image = ApplicationContext.Current.Services.MediaService.GetById(int.Parse(imageId));
                    imageUrls.Add(GetCropUpUrl(image, cropUpAlias));
                }
            }

            return imageUrls;
        }
開發者ID:pjengaard,項目名稱:lilleGrundetDk,代碼行數:21,代碼來源:MediaMapper.cs

示例4: NodeVisible

 public static bool NodeVisible(Node node)
 {
     if (node.HasProperty("umbracoNaviHide")) return !node.GetProperty<bool>("umbracoNaviHide");
     if (node.HasProperty("visible")) return node.GetProperty<bool>("visible");
     return false;
 }
開發者ID:joeriks,項目名稱:UmbracoPublishedContentApi,代碼行數:6,代碼來源:ContentHelpers.cs

示例5: MatchesPropertyValue

        private static bool MatchesPropertyValue(int pageId)
        {
            var appSetting = Settings.GetValueFromKey(Settings.AppKey_Properties);

            if (string.IsNullOrEmpty(appSetting))
                return false;

            var node = new Node(pageId);
            var items = appSetting.Split(new[] { Settings.COMMA }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var item in items)
            {
                var parts = item.Split(new[] { Settings.COLON }, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length == 0)
                    continue;

                var propertyAlias = parts[0];
                var propertyValue = Settings.CHECKBOX_TRUE;

                if (parts.Length > 1)
                    propertyValue = parts[1];

                var property = node.GetProperty(propertyAlias);
                if (property == null)
                    continue;

                var match = string.Equals(property.Value, propertyValue, StringComparison.InvariantCultureIgnoreCase);
                if (match)
                    return true;
            }

            return false;
        }
開發者ID:jonrandahl,項目名稱:umbraco-https-redirect,代碼行數:33,代碼來源:ApplicationEventsHandler.cs

示例6: Document_BeforePublish

        void Document_BeforePublish(Document doc, PublishEventArgs e)
        {
            // When document is renamed or 'umbracoUrlName' property value is added/updated
            #if !DEBUG
            try
            #endif
            {
                Node node = new Node(doc.Id);
                if (node.Name != doc.Text && !string.IsNullOrEmpty(node.Name)) // If name is null, it's a new document
                {
                    // Rename occurred
                    UrlTrackerRepository.AddUrlMapping(doc, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Renamed);

                    if (BasePage.Current != null)
                        BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", doc.Id));
                }
                if (doc.getProperty("umbracoUrlName") != null && node.GetProperty("umbracoUrlName") != null && node.GetProperty("umbracoUrlName").Value != doc.getProperty("umbracoUrlName").Value.ToString())
                {
                    // 'umbracoUrlName' property value added/changed
                    UrlTrackerRepository.AddUrlMapping(doc, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.UrlOverwritten);

                    if (BasePage.Current != null)
                        BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", doc.Id));
                }
            }
            #if !DEBUG
            catch (Exception ex)
            {
                ex.LogException(doc.Id);
            }
            #endif
        }
開發者ID:neehouse,項目名稱:UrlTracker,代碼行數:32,代碼來源:UrlTrackerApplicationBase.cs

示例7: sendForm

        public formResponse sendForm(formRequest request)
        {
            formResponse nr = new formResponse();
            nr.Result = "1";
            nr.Msg = string.Empty;

            try
            {
                // start Node Factory
                Node page = new Node(request.Id);

                string autoResponderEmail = string.Empty;
                string autoResponderId = string.Empty;
                if (page.GetProperty("emailField") != null)
                {
                    autoResponderId = page.GetProperty("emailField").Value;
                }

                // construct the email message
                int rowCount = 0;
                string message = "<html><head></head><body><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"font-family: sans-serif; font-size: 13px; color: #222; border-collapse: collapse;\">";
                for (int i = 0; i < request.Values.Length; i++)
                {
                    string name = request.Names[i];
                    //string nodeName = string.Empty;
                    int index = request.FieldIds[i].LastIndexOf('_') + 1;
                    if (index > 0)
                    {
                        string fullId = request.FieldIds[i].Substring(index, request.FieldIds[i].Length - index);

                        if (fullId == autoResponderId)
                        {
                            autoResponderEmail = request.Values[i];
                        }

                        int id;
                        if (int.TryParse(fullId, out id))
                        {
                            Node node = new Node(id);
                            if (node != null)
                            {
                                //nodeName = node.Name;
                                name = node.Name;
                                try
                                {
                                    if (node.GetProperty("label").Value.Length > 0)
                                    {
                                        name = node.GetProperty("label").Value;
                                    }
                                    else if (node.NodeTypeAlias == "PliableText")
                                    {
                                        if (node.GetProperty("defaultValue").Value.Length > 0)
                                        {
                                            name = node.GetProperty("defaultValue").Value;
                                        }
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                    if (name.Length > 0)
                    {
                        rowCount++;
                        try
                        {
                            if (rowCount % 2 == 0)
                            {
                                message += string.Format("<tr><td style=\"background-color: #ffffff; padding: 4px 8px; vertical-align: top; width: 120px;\">{0}</td><td style=\"background-color: #ffffff; padding: 4px 8px; vertical-align: top;\">{1}</td></tr>", name, request.Values[i]);
                            }
                            else
                            {
                                message += string.Format("<tr><td style=\"background-color: #ebf5ff; padding: 4px 8px; vertical-align: top; width: 120px;\">{0}</td><td style=\"background-color: #ebf5ff; padding: 4px 8px; vertical-align: top;\">{1}</td></tr>", name, request.Values[i]);
                            }
                        }
                        catch { }
                    }
                }
                message += "</table></body></html>";

                // determine the to address
                string emailTo = page.GetProperty("toAddress").Value;

                if (string.IsNullOrEmpty(emailTo))
                {
                    emailTo = ConfigurationManager.AppSettings["PliableForm.defaultToAddress"];
                    if (emailTo == null)
                    {
                        emailTo = umbraco.library.GetDictionaryItem("PliableForm.defaultToAddress");
                    }
                }
                string subject = page.GetProperty("emailSubject").Value;
                if (string.IsNullOrEmpty(subject))
                {
                    subject = ConfigurationManager.AppSettings["PliableForm.defaultEmailSubject"];
                    if (subject == null)
                    {
                        subject = umbraco.library.GetDictionaryItem("PliableForm.defaultEmailSubject");
                    }
                }
//.........這裏部分代碼省略.........
開發者ID:promboutssogeti,項目名稱:Pliable-Form,代碼行數:101,代碼來源:PliableSender.asmx.cs

示例8: GetMultiStoreContentProperty

		// unsure about location! (maybe another service)
		public string GetMultiStoreContentProperty(int contentId, string propertyAlias, ILocalization localization, bool globalOverrulesStore = false)
		{
			var examineNode = Helpers.GetNodeFromExamine(contentId, "GetMultiStoreItem::" + propertyAlias);
			if (localization == null)
			{
				localization = StoreHelper.CurrentLocalization;
			}
			var multiStoreAlias = StoreHelper.CreateMultiStorePropertyAlias(propertyAlias, localization.StoreAlias);
			var multiStoreMultiCurrencyAlias = StoreHelper.CreateFullLocalizedPropertyAlias(propertyAlias, localization);
			if (examineNode != null)
			{
				
				if (multiStoreAlias.StartsWith("description"))
				{
					multiStoreAlias = "RTEItem" + multiStoreAlias;
					propertyAlias = "RTEItem" + propertyAlias;
				}

				if (globalOverrulesStore && examineNode.Fields.ContainsKey(propertyAlias))
				{
					return examineNode.Fields[propertyAlias] ?? string.Empty;
				}

				if (examineNode.Fields.ContainsKey(multiStoreMultiCurrencyAlias))
				{
					return examineNode.Fields[multiStoreMultiCurrencyAlias] ?? string.Empty;
				}

				if (examineNode.Fields.ContainsKey(multiStoreAlias))
				{
					return examineNode.Fields[multiStoreAlias] ?? string.Empty;
				}

				if (examineNode.Fields.ContainsKey(propertyAlias))
				{
					return examineNode.Fields[propertyAlias] ?? string.Empty;
				}

				Log.Instance.LogDebug("GetMultiStoreContentProperty Fallback to node after this");
			}

			var node = new Node(contentId);
			if (node.Name != null)
			{
				var property = node.GetProperty(propertyAlias);
				if (globalOverrulesStore && property != null && !string.IsNullOrEmpty(property.Value))
				{
					return property.Value;
				}
				var propertyMultiStoreMultiCurrency = node.GetProperty(multiStoreMultiCurrencyAlias);
				if (propertyMultiStoreMultiCurrency != null && !string.IsNullOrEmpty(propertyMultiStoreMultiCurrency.Value))
				{
					return propertyMultiStoreMultiCurrency.Value;
				}
				var propertyMultistore = node.GetProperty(multiStoreAlias);
				if (propertyMultistore != null && !string.IsNullOrEmpty(propertyMultistore.Value))
				{
					return propertyMultistore.Value;
				}
				if (property != null)
				{
					return property.Value;
				}
			}
			return string.Empty;
		}
開發者ID:Chuhukon,項目名稱:uWebshop-Releases,代碼行數:67,代碼來源:UmbracoApplication.cs

示例9: ExamineEventsInternal_GatheringNodeData

        void ExamineEventsInternal_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
        {
            //need to fudge rte field so that we have internal link nodeids in the internal index
            var rteFields = RteFields;

            if (e.IndexType == IndexTypes.Content)
            {
                var d = new Document(e.NodeId);
                foreach (var rteField in rteFields)
                {
                    if (d.getProperty(rteField) != null && d.getProperty(rteField).Value != null)
                    {
                        var rteEncoded = HttpUtility.HtmlEncode(d.getProperty(rteField).Value.ToString().Replace("localLink:", "localLink: ").Replace("}", " } "));
                        e.Fields.Add("rteLink" + rteField, rteEncoded);
                    }
                }

                var treePickerFields = TreePickerFields;
                foreach (var treePickerField in treePickerFields)
                {
                    if (e.Fields.ContainsKey(treePickerField))
                    {
                        var content = e.Fields[treePickerField];

                        // if it's a csv type and there's more than one item,
                        // separate with a space so the nodes are indexed separately
                        if (content.Contains(","))
                        {
                            content = content.Replace(",", " ");
                        }
                        else
                        {
                            // if it's an XML type tree picker, get the xml and transform into a space separated list
                            var node = new Node(e.NodeId);
                            var value = node.GetProperty(treePickerField).Value;

                            if (value.Contains("<MultiNodePicker"))
                            {
                                var dynamicXml = new DynamicXml(value);
                                content = string.Join(" ", dynamicXml.Descendants().Select(de => de.InnerText));
                            }
                        }
                        e.Fields[treePickerField] = content;
                    }
                }

                e.Fields.Add("IsPublished", d.Published.ToString());
            }
        }
開發者ID:ismailmayat,項目名稱:cogitemusage,代碼行數:49,代碼來源:ExamineEvents.cs

示例10: GetTemplateNode

 Node GetTemplateNode(Node nMail)
 {
     // Determine if any basic template has been selected for this email
     string templateId = nMail.GetProperty(EnmUmbracoPropertyAlias.emailTemplate);
     int nodeId;
     if (int.TryParse(templateId, out nodeId))
         return new Node(nodeId);
     else
         return null;
 }
開發者ID:PerplexInternetmarketing,項目名稱:PerplexMail-for-Umbraco,代碼行數:10,代碼來源:Email.cs

示例11: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     var mainForumNode = new Node(new ForumFactory().ReturnRootForumId());
     litLoginDescription.Text = mainForumNode.GetProperty("loginDescription").Value;
 }
開發者ID:wakkomail,項目名稱:community-framework,代碼行數:5,代碼來源:Login.ascx.cs

示例12: MapNewsItem

 public NewsItem MapNewsItem(Node newsNode)
 {
     return new NewsItem
     {
         Id = newsNode.Id,
         Title = !string.IsNullOrEmpty(newsNode.GetProperty<string>("Title"))
             ? newsNode.GetProperty<string>("Title")
             : newsNode.Name,
         Text = newsNode.GetProperty<string>("Content"),
         Author = newsNode.GetProperty<string>("Author"),
         PublishedTime = newsNode.GetProperty<DateTime>("PublishedTime"),
         Url = newsNode.Url
     };
 }
開發者ID:golandez,項目名稱:UmbracoSample,代碼行數:14,代碼來源:NewsRepository.cs

示例13: GetCreatedBy

 protected string GetCreatedBy(Node notice)
 {
     return notice.GetProperty("createdBy") != null ? notice.GetProperty("createdBy").Value : "-";
 }
開發者ID:wakkomail,項目名稱:community-framework,代碼行數:4,代碼來源:Noticeboard.ascx.cs

示例14: Execute

        /// <summary>
        /// Executes the specified URL.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <returns>Returns whether the NotFoundHandler has a match.</returns>
        public bool Execute(string url)
        {
            HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.NotFound;

            var success = false;

            // get the current domain name
            var domainName = HttpContext.Current.Request.ServerVariables["SERVER_NAME"];

            // if there is a port number, append it
            var port = HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
            if (!string.IsNullOrEmpty(port) && port != "80")
            {
                domainName = string.Concat(domainName, ":", port);
            }

            // get the root node id of the domain
            var rootNodeId = Domain.GetRootFromDomain(domainName);

            try
            {
                if (rootNodeId > 0)
                {
                    // get the node
                    var node = new Node(rootNodeId);

                    // get the property that holds the node id for the 404 page
                    var property = node.GetProperty("umbracoPageNotFound");
                    if (property != null)
                    {
                        var errorId = property.Value;
                        if (!string.IsNullOrEmpty(errorId))
                        {
                            // if the node id is numeric, then set the redirectId
                            success = int.TryParse(errorId, out this._redirectId);
                        }
                    }
                }
            }
            catch
            {
                success = false;
            }

            return success;
        }
開發者ID:bokmadsen,項目名稱:uComponents,代碼行數:51,代碼來源:MultiSitePageNotFoundHandler.cs

示例15: GetImageUrl

        /// <summary>
        /// Method for getting an image url with a specified width and height
        /// </summary>
        /// <param name="node">Node with image property</param>
        /// <param name="imagePropertyAlias">Property alias</param>
        /// <param name="width">The width of the image in pixels</param>
        /// <param name="height">The height of the image in pixels</param>
        /// <returns>string</returns>
        public static string GetImageUrl(Node node, string imagePropertyAlias, int width = 0, int height = 0)
        {
            string imageUrl = string.Empty;
            if (!string.IsNullOrEmpty(node.GetProperty<string>(imagePropertyAlias)))
            {
                var image =
                    ApplicationContext.Current.Services.MediaService.GetById(node.GetProperty<int>(imagePropertyAlias));

                return GetCropUpUrl(image, width, height);
            }

            return imageUrl;
        }
開發者ID:pjengaard,項目名稱:lilleGrundetDk,代碼行數:21,代碼來源:MediaMapper.cs


注:本文中的umbraco.NodeFactory.Node.GetProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。