This page shows how to create an exclude filter.
Using an exclude filter
Suppose you want to reflect everything but private fields. Now you could use the include filter and specify everything which should be reflected. You will end up with a realy big block of code declaring the rules. To make things easier, you can use the include filter in conjunction with the invert filter as follows:
Example
1// Create the filter 2IncludeFilter includeFilter = new IncludeFilter(); 3includeFilter.Rules.Add(new FilterRule(FilterModifiers.Private, FilterElements.Field)); 4 5IFilter filter = new InvertFilter(includeFilter); 6 7// Do the reflection 8NRAssembly nrAssembly; 9try 10{ 11 Reflector reflector = new Reflector(); 12 nrAssembly = reflector.Reflect("MyAssembly.dll", ref filter); 13} 14catch(Exception ex) 15{ 16 Console.WriteLine("Exception while reflecting: " + ex.Message); 17 return; 18} 19 20// Output the results 21PrintVisitor printVisitor = new PrintVisitor(); 22nrAssembly.Accept(printVisitor);
See Also