public void AddCodeVisitor(CodeVisitorBase visitor, object key) { if (visitor == null) throw new ArgumentNullException("visitor"); if (key == null) throw new ArgumentNullException("key"); CompositeCodeVisitor visitorsForType; _visitors.TryGetValue(key, out visitorsForType); if (visitorsForType == null) { visitorsForType = new CompositeCodeVisitor(); _visitors.Add(key, visitorsForType); } visitorsForType.AddCodeVisitor(visitor); }
public void BeginVisitingType(TypeDefinition typeBeingVisited) { if (typeBeingVisited == null) throw new ArgumentNullException("typeBeingVisited"); _currentVisitor = null; AddVisitorToCurrentComposite(typeBeingVisited); // include all enclosing types from the type being visited GetEnclosingTypes(typeBeingVisited).ForEach(et => AddVisitorToCurrentComposite(et)); AddVisitorToCurrentComposite(AssemblyKey); // AssemblyKey indicates that the visitor is valid for all types }
public void EndVisitingType() { _currentVisitor = null; }
private void AddVisitorToCurrentComposite(object visitorKey) { CompositeCodeVisitor visitor; _visitors.TryGetValue(visitorKey, out visitor); if (visitor != null) { if (_currentVisitor == null) _currentVisitor = new CompositeCodeVisitor(); _currentVisitor.AddCodeVisitor(visitor); } }