Example #1
0
        private IEnumerable<FilterData> findFilters()
        {
            var types = new List<Type>();

            AppDomain.CurrentDomain.GetAssemblies().ForEach(assembly =>
            {
                types.AddRange(assembly.GetTypes().Where(t => t.Name.ToLower().EndsWith("filter")));
            });

            var filters = new List<FilterData>();

            foreach (var type in types)
            {
                var methods = type.GetMethods();

                var filter = new FilterData
                {
                    Type = type,
                    Priority = getPriority(type),
                    BeforeFilter = methods.Any(m => m.Name.ToLower() == "before"),
                    AfterFilter = methods.Any(m => m.Name.ToLower() == "after")
                };

                if (filter.AfterFilter || filter.BeforeFilter)
                {
                    filters.Add(filter);
                }
            }

            return filters;
        }
        private IEnumerable<FilterData> findFilters(IEnumerable<Type> types)
        {
            var filters = new List<FilterData>();

            foreach (var type in types)
            {
                var methods = type.GetMethods();

                var filter = new FilterData
                {
                    Type = type,
                    Priority = getPriority(type),
                    BeforeFilter = methods.Any(m => m.Name.ToLower() == "before"),
                    AfterFilter = methods.Any(m => m.Name.ToLower() == "after")
                };

                if (filter.AfterFilter || filter.BeforeFilter)
                {
                    filters.Add(filter);
                }
            }

            return filters;
        }
 public object Create(FilterData filterData)
 {
     return ObjectFactory.GetInstance(filterData.Type);
 }