BoC.Sitecore.Mvc.WildcardValueProvider.GetValue C# (CSharp) Method

GetValue() public method

public GetValue ( string key ) : System.Web.Mvc.ValueProviderResult
key string
return System.Web.Mvc.ValueProviderResult
        public ValueProviderResult GetValue(string key)
        {
            if (string.IsNullOrEmpty(key) || PageContext.CurrentOrNull == null || PageContext.Current.Item == null
                || !key.StartsWith("wildcardItem"))
                return null;

            var requestedWildcard = 0;
            if (key.Length > "wildcardItem".Length)
            {
                requestedWildcard = Int16.Parse(key.Substring("wildcardItem".Length)) - 1;
            }
            var wildcardItem = PageContext.Current.Item;
            var i = 0;
            using (new SecurityDisabler())
            {
                var currentWild = wildcardItem.Paths.FullPath.Count(c => c == '*')-1;
                if (currentWild < 0)
                    return null;
                while (wildcardItem != null)
                {
                    if (wildcardItem.Name == "*")
                    {
                        if (requestedWildcard == currentWild)
                        {
                            var val = WebUtil.GetUrlName(i);
                            return new ValueProviderResult(val, val, CultureInfo.InvariantCulture);
                        }
                        currentWild--;
                    }
                    wildcardItem = wildcardItem.Parent;
                    if (wildcardItem != null && !wildcardItem.Paths.FullPath.Contains("*"))
                        break;
                    i++;
                }
            }
            return null;
        }
WildcardValueProvider