Пример #1
0
        private IEnumerable <MethodInfo> MakeActions()
        {
            var knownMethods = IndexMethod.AsSingle().Concat(Formatters);
            var methods      = PaperType.GetMethods(BindingFlags.Public | BindingFlags.Instance).Except(knownMethods);

            foreach (var method in methods)
            {
                if (method.DeclaringType.Namespace.StartsWith("System"))
                {
                    continue;
                }

                if (typeof(void).IsAssignableFrom(method.ReturnType) ||
                    typeof(Ret).IsAssignableFrom(method.ReturnType)

                    || typeof(string).IsAssignableFrom(method.ReturnType) ||
                    typeof(Href).IsAssignableFrom(method.ReturnType) ||
                    typeof(Uri).IsAssignableFrom(method.ReturnType) ||
                    typeof(UriString).IsAssignableFrom(method.ReturnType)

                    || typeof(Ret <string>).IsAssignableFrom(method.ReturnType) ||
                    typeof(Ret <Href>).IsAssignableFrom(method.ReturnType) ||
                    typeof(Ret <Uri>).IsAssignableFrom(method.ReturnType) ||
                    typeof(Ret <UriString>).IsAssignableFrom(method.ReturnType))
                {
                    yield return(method);
                }
            }
        }
Пример #2
0
        private IEnumerable <MethodInfo> MakeFactories()
        {
            var knownMethods = IndexMethod.AsSingle().Concat(Formatters).Concat(Actions);
            var methods      = PaperType.GetMethods(BindingFlags.Public | BindingFlags.Instance).Except(knownMethods);

            foreach (var method in methods)
            {
                if (typeof(Sort).IsAssignableFrom(method.ReturnType) ||
                    typeof(Page).IsAssignableFrom(method.ReturnType) ||
                    typeof(IFilter).IsAssignableFrom(method.ReturnType))
                {
                    if (!method.GetParameters().Any())
                    {
                        yield return(method);
                    }
                }
            }
        }