Rebel.Cms.Web.RouteDataExtensions.GetOptionalString C# (CSharp) Method

GetOptionalString() public static method

public static GetOptionalString ( this routeData, string key ) : string
routeData this
key string
return string
        public static string GetOptionalString(this RouteData routeData, string key)
        {
            if (routeData.Values.Any(x => x.Key == key))
            {
                if (routeData.Values.Where(x => x.Key == key).First().Value is string)
                {
                    return routeData.GetRequiredString(key);   
                }                
                throw new InvalidOperationException("The value found with the specified key is not a string");
            }
            return "";
        }