Пример #1
0
        private static void ProcessMethodSitemaps(IDictionary <Type, List <Tuple <string, SitemapAttribute> > > manifest, Type type, IEnumerable <MethodInfo> methods, SitemapAttribute defaultAttribute = null)
        {
            foreach (var method in methods)
            {
                SitemapAttribute attribute;
                if (defaultAttribute != null)
                {
                    attribute = defaultAttribute;
                }
                else
                {
                    attribute = method.GetCustomAttributes(false).OfType <SitemapAttribute>().FirstOrDefault();
                    if (attribute == null)
                    {
                        continue;
                    }
                }

                // Support the user changing the action name with an attribute
                var action     = method.Name;
                var actionName = method.GetCustomAttributes(false).OfType <ActionNameAttribute>().FirstOrDefault();
                if (actionName != null)
                {
                    action = actionName.Name;
                }

                if (!manifest.ContainsKey(type))
                {
                    manifest.Add(type, new List <Tuple <string, SitemapAttribute> >());
                }

                manifest[type].Add(new Tuple <string, SitemapAttribute>(action, attribute));
            }
        }
Пример #2
0
        private static void ProcessMethodSitemaps(IDictionary<Type, List<Tuple<string, SitemapAttribute>>> manifest, Type type, IEnumerable<MethodInfo> methods, SitemapAttribute defaultAttribute = null)
        {
            foreach(var method in methods)
            {
                SitemapAttribute attribute;
                if(defaultAttribute != null)
                {
                    attribute = defaultAttribute;
                }
                else
                {
                    attribute = method.GetCustomAttributes(false).OfType<SitemapAttribute>().FirstOrDefault();
                    if(attribute == null)
                    {
                        continue;
                    }
                }

                // Support the user changing the action name with an attribute
                var action = method.Name;
                var actionName = method.GetCustomAttributes(false).OfType<ActionNameAttribute>().FirstOrDefault();
                if(actionName != null)
                {
                    action = actionName.Name;
                }

                if(!manifest.ContainsKey(type))
                {
                    manifest.Add(type, new List<Tuple<string, SitemapAttribute>>());
                }

                manifest[type].Add(new Tuple<string, SitemapAttribute>(action, attribute));
            }
        }