static void Main(string[] args) { var firsts = new List<IColor> { new Red(), new Green(), new Blue() }; var seconds = new List<IColor> { new Red(), new Green(), new Blue() }; var firstVisitor = new FirstVisitor(new ColorProcessor()); foreach (var first in firsts) { var secondVisitor = first.AcceptVisitor(firstVisitor); foreach (var second in seconds) { Console.WriteLine(second.AcceptVisitor(secondVisitor)); } } }
VisitStatus IPropertyVisitor.VisitProperty <TProperty2, TContainer2, TValue2>(TProperty2 property, ref TContainer2 container, ref ChangeTracker changeTracker) { if (visitedFirst) { return(VisitStatus.Handled); } if (!Result) { return(VisitStatus.Handled); } visitedFirst = true; if (property.IsContainer) { var bag = PropertyBagResolver.Resolve <TValue2>(); if (bag != null) { var ct = new ChangeTracker(); var v = property.GetValue(ref container); var visitor2 = new FirstVisitor(Visitor); bag.Accept(ref v, ref visitor2, ref ct); Result = visitor2.Result; } } return(VisitStatus.Handled); }
static void Main(string[] args) { var firsts = new List <IColor> { new Red(), new Green(), new Blue() }; var seconds = new List <IColor> { new Red(), new Green(), new Blue() }; var firstVisitor = new FirstVisitor(new ColorProcessor()); foreach (var first in firsts) { var secondVisitor = first.AcceptVisitor(firstVisitor); foreach (var second in seconds) { Console.WriteLine(second.AcceptVisitor(secondVisitor)); } } }
VisitStatus IPropertyVisitor.VisitCollectionProperty <TProperty2, TContainer2, TValue2>(TProperty2 property, ref TContainer2 container, ref ChangeTracker changeTracker) { if (visitedFirst) { return(VisitStatus.Handled); } if (!Result) { return(VisitStatus.Handled); } visitedFirst = true; var visitor2 = new FirstVisitor(Visitor); var vs = visitor2.VisitCollectionProperty <TProperty2, TContainer2, TValue2>(property, ref container, ref changeTracker); Result = visitor2.Result; return(vs); }