private ViewMode GuessViewMode(string action)
        {
            if (action == null)
            {
                action = "";
            }
            ViewMode result;

            foreach (ViewMode mode in
                     from ViewMode m in System.Enum.GetValues(typeof(ViewMode))
                     where m != ViewMode.Unknow
                     select m)
            {
                string pattern = (KeyValueInfoAttribute.GetValue(mode, "MatchPattern") as string) ?? "^$";
                if (Regex.Match(action, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled).Success)
                {
                    result = mode;
                    return(result);
                }
            }
            result = ViewMode.Unknow;
            return(result);
        }
Esempio n. 2
0
 public static string DisplayNameForMode(this HtmlHelper helper)
 {
     return(KeyValueInfoAttribute.GetValue(helper.ViewMode(), "Text") as string);
 }