本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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");
}
}
//.........这里部分代码省略.........
示例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;
}
示例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());
}
}
示例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;
}
示例11: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var mainForumNode = new Node(new ForumFactory().ReturnRootForumId());
litLoginDescription.Text = mainForumNode.GetProperty("loginDescription").Value;
}
示例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
};
}
示例13: GetCreatedBy
protected string GetCreatedBy(Node notice)
{
return notice.GetProperty("createdBy") != null ? notice.GetProperty("createdBy").Value : "-";
}
示例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;
}
示例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;
}