Exemplo n.º 1
0
        public void Add(SearchScope scope, SearchBy searchBy, Operator op, string searchText)
        {
            var searchPredicate = HookExtensions.FormatSearchClause <T>(searchBy, op, searchText);

            switch (scope)
            {
            case SearchScope.ExecutingAssembly:
                _hook.AddRange(Assembly.GetExecutingAssembly().GetHooks <T>(searchPredicate));
                break;

            case SearchScope.EntryAssembly:
                _hook.AddRange(Assembly.GetEntryAssembly().GetHooks <T>(searchPredicate));
                break;

            case SearchScope.CallingAssembly:
                _hook.AddRange(Assembly.GetCallingAssembly().GetHooks <T>(searchPredicate));
                break;

            case SearchScope.CurrentDirectory:
                List <Assembly> assemblies = DirectoryExtensions.GetAssemblies(Environment.CurrentDirectory, "*.dll");
                assemblies.AddRange(DirectoryExtensions.GetAssemblies(Environment.CurrentDirectory, "*.exe"));
                foreach (var item in assemblies)
                {
                    _hook.AddRange(item.GetHooks(searchPredicate));
                }
                break;

            default:
                throw new InvalidOperationException("Invalid SearchScope: " + scope);
            }
        }