Example #1
0
        public static string ResolveText <T>(Dictionary <string, T> dict, string input, Func <T, string> linkGenerator, Func <string, string> failureHandler = null)
        {
            if (dict == null)
            {
                return(input);
            }
            return(LinkParser.Resolve(input, s =>
            {
                T item;
                if (dict.TryGetValue(s, out item))
                {
                    if (linkGenerator != null)
                    {
                        return linkGenerator(item);
                    }
                    else
                    {
                        Debug.Assert(linkGenerator == null);
                        return item.ToString();
                    }
                }
                else
                {
                    if (failureHandler != null)
                    {
                        return failureHandler(s);
                    }

                    return null;
                }
            }));
        }
Example #2
0
 private static string ResolveText(Dictionary <string, MetadataItem> dict, string input)
 {
     if (string.IsNullOrEmpty(input))
     {
         return(null);
     }
     return(LinkParser.ResolveToMarkdownLink(dict, input));
 }
Example #3
0
 public static string ResolveToMarkdownLink(Dictionary <string, MetadataItem> dict, string input)
 {
     return(LinkParser.ResolveText(dict, input, s =>
                                   string.Format("[{0}]({1})", s.Name, s.Href), s => string.Format("[{0}](#)", s)
                                   ));
 }