internal PropertyResult(IPublishedContentProperty source, PropertyResultType type) { if (source == null) throw new ArgumentNullException("source"); Alias = source.Alias; Value = source.Value; Version = source.Version; PropertyType = type; }
/// <summary> /// Returns value from property casted to string type without rendering Macros in RTE property. If property does not exist returns String.Empty. /// </summary> /// <param name="page">Umbraco cached content</param> /// <param name="propertyName">Name of the property which value is casted to String type</param> /// <returns>Property value casted to String type</returns> public static string GetPropertyUnrenderedValueAsString(this IPublishedContent page, string propertyName) { string result = string.Empty; IPublishedContentProperty prop = page.Properties.Where(p => p.PropertyTypeAlias == propertyName).FirstOrDefault(); if (prop != null && prop.Value != null) { result = prop.Value.ToString(); } return(result); }
public static bool HasValue(this IPublishedContentProperty prop) { if (prop == null) { return(false); } if (prop.Value == null) { return(false); } return(!prop.Value.ToString().IsNullOrWhiteSpace()); }
internal PropertyResult(IPublishedContentProperty source, PropertyResultType type) { if (source == null) { throw new ArgumentNullException("source"); } Alias = source.Alias; Value = source.Value; Version = source.Version; PropertyType = type; }
public static IEnumerable <dynamic> GetRss(IPublishedContentProperty property) { List <dynamic> result = new List <dynamic>(); if (property != null) { foreach (XElement element in XDocument.Load(property.Value.ToString()).Descendants("item")) { dynamic data = new ExpandoObject(); foreach (XElement item in element.Descendants()) { ((IDictionary <string, object>)data).Add(item.Name.LocalName, item.Value); } result.Add(data); } } return(result); }
/// <summary> /// Gets a property value from Umbraco when a string is expected, nulls are returned as empty string /// </summary> /// <param name="node"></param> /// <param name="alias"></param> /// <returns></returns> public static string GetStringPropertyValue(this IPublishedContent node, string alias) { string returnValue = string.Empty; IPublishedContentProperty prop = node.GetProperty(alias); if (prop != null) { if (prop.Value != null) { if (prop.Value is string) { returnValue = prop.Value.ToString(); } } } return(returnValue); }
public static string GetSliderUrl(DynamicPublishedContent image) { string result = string.Empty; IPublishedContentProperty externalUrlProperty = image.GetProperty("externalUrl"); if (externalUrlProperty != null) { result = externalUrlProperty.Value.ToString(); } IPublishedContentProperty internalUrlProperty = image.GetProperty("internalUrl"); if (internalUrlProperty != null) { if (internalUrlProperty.Value.ToString() != string.Empty) { result = new Document(Convert.ToInt32(internalUrlProperty.Value)).ToNode().NiceUrl; } } return(result); }
/// <summary> /// Gets a property value from Umbraco when an bool is expected, nulls are returned as false /// </summary> /// <param name="node"></param> /// <param name="alias"></param> /// <returns></returns> public static bool GetBoolPropertyValue(this IPublishedContent node, string alias) { bool returnValue = false; IPublishedContentProperty prop = node.GetProperty(alias); if (prop != null) { if (prop.Value != null) { if (prop.Value is string) { if (prop.Value.ToString() == "1") { returnValue = true; } } } } return(returnValue); }
/// <summary> /// Gets a property value from Umbraco when an int is expected, nulls are returned as -1 /// </summary> /// <param name="node"></param> /// <param name="alias"></param> /// <returns></returns> public static int GetIntPropertyValue(this IPublishedContent node, string alias) { int returnValue = -1; int tempint = -1; IPublishedContentProperty prop = node.GetProperty(alias); if (prop != null) { if (prop.Value != null) { if (prop.Value is string) { if (int.TryParse(prop.Value.ToString(), out tempint)) { returnValue = int.Parse(prop.Value.ToString()); } } } } return(returnValue); }
public ContentBuilder AddProperty(IPublishedContentProperty property) { _properties.Add(property); return(this); }
internal static IProperty ConvertToNodeProperty(this IPublishedContentProperty prop) { return(new PropertyResult(prop.Alias, prop.Value.ToString(), prop.Version)); }
public ContentBuilder AddProperty(IPublishedContentProperty property) { _properties.Add(property); return this; }
public static IEnumerable<dynamic> GetRss(IPublishedContentProperty property) { List<dynamic> result = new List<dynamic>(); if (property != null) { foreach (XElement element in XDocument.Load(property.Value.ToString()).Descendants("item")) { dynamic data = new ExpandoObject(); foreach (XElement item in element.Descendants()) { ((IDictionary<string, object>)data).Add(item.Name.LocalName, item.Value); } result.Add(data); } } return result; }