/// <summary> /// Returns the first non null value found. /// </summary> /// <param name="value"></param> /// <param name="other"></param> /// <returns></returns> public static string Coalesce(this string value, string other) { return value.Coalesce(new[] {other}); }
// Get content from IPublishedContent public static string GetUrl( this UmbracoHelper umbracoHelper, IPublishedContent publishedContent ) { return umbracoHelper.Coalesce(publishedContent.GetPropertyValue("link")); }
// Get title from IPublishedContent public static string GetTitle(this UmbracoHelper umbracoHelper, IPublishedContent publishedContent) { return umbracoHelper.Coalesce(publishedContent.GetPropertyValue("listHeading"), publishedContent.GetPropertyValue("pageHeading"), publishedContent.Name); }
// Get introduction from IPublishedContent public static string GetIntro( this UmbracoHelper umbracoHelper, IPublishedContent publishedContent ) { return umbracoHelper.Coalesce(publishedContent.GetPropertyValue("listIntroduction"), publishedContent.GetPropertyValue("pageIntroduction")); }
// Get image from IPublishedContent public static string GetImageUrl( this UmbracoHelper umbracoHelper, IPublishedContent publishedContent ) { var image = umbracoHelper.Coalesce(publishedContent.GetPropertyValue("listImage"), publishedContent.GetPropertyValue("pageImage")); return image; }
public static ColorToken[] Coalesce(this IEnumerable<ColorToken> tokens, ConsoleColor color) { return tokens.Coalesce(color, null); }