Exemplo n.º 1
0
        public DocumentLocationFragment Resolve(DocumentLocationFragment fragment)
        {
            var current = fragment;

            UnresolvedMacros = Enumerable.Empty <string>();

            foreach (var resolver in myResolvers)
            {
                current          = resolver.Resolve(current);
                UnresolvedMacros = resolver.UnresolvedMacros;
            }

            return(current);
        }
Exemplo n.º 2
0
        public DocumentLocationFragment Resolve(DocumentLocationFragment fragment)
        {
            Contract.RequiresNotNull(fragment, "fragment");

            myUnresolvedMacros.Clear();

            var matches = myMacroPattern.Value.Matches(fragment.UrlString);

            if (matches.Count == 0)
            {
                // no macro found
                return(fragment);
            }

            var url = fragment.UrlString;

            foreach (Match match in matches)
            {
                var macro = match.Value;
                var value = GetMacroValue(macro.Substring(2, macro.Length - 3));

                if (value == null)
                {
                    myUnresolvedMacros.Add(macro);
                }
                else
                {
                    url = url.Replace(macro, value);
                }
            }

            if (url == fragment.UrlString)
            {
                return(fragment);
            }
            else
            {
                return(CreateFragment(fragment.GetType(), url));
            }
        }
Exemplo n.º 3
0
        private int CalculateLocationUID(DocumentLocationFragment fragment)
        {
            var matches = myMacroPattern.Value.Matches(fragment.UrlString);

            if (matches.Count == 0)
            {
                // no macro found
                return(fragment.UrlString.GetHashCode());
            }

            var url = fragment.UrlString;

            foreach (Match match in matches)
            {
                var macro = match.Value;
                var value = GetMacroValue(macro.Substring(2, macro.Length - 3));

                if (value != null)
                {
                    url = url.Replace(macro, value);
                }
            }
            return(url.GetHashCode());
        }
Exemplo n.º 4
0
 private void OnDeleteUrl(DocumentLocationFragment url)
 {
     Urls.Remove(url);
 }
Exemplo n.º 5
0
 public DocumentLocationFragment Resolve(DocumentLocationFragment fragment)
 {
     return(fragment);
 }