public override void Accept(ref EntityContainer container, IPropertyVisitor visitor) { var count = container.m_Manager.GetComponentCount(container.m_Entity); var listContext = new ListContext <IList <StructProxy> > { Property = this, Value = null, Index = -1, Count = count }; // @TODO improve, split the deps HashSet <Type> primitiveTypes = new HashSet <Type>(); // try to gather the primitive types for that visitor var entityVisitor = visitor as IPrimitivePropertyVisitor; if (entityVisitor != null) { primitiveTypes = entityVisitor.SupportedPrimitiveTypes(); } else { // @TODO remove that dependency // Fallback on the optimized visitor for now primitiveTypes = OptimizedVisitor.SupportedTypes(); } if (visitor.BeginList(ref container, listContext)) { for (var i = 0; i < count; i++) { var item = Get(ref container, i, primitiveTypes); var context = new SubtreeContext <StructProxy> { Property = this, Value = item, Index = i }; if (visitor.BeginContainer(ref container, context)) { item.PropertyBag.VisitStruct(ref item, visitor); } visitor.EndContainer(ref container, context); } } visitor.EndList(ref container, listContext); }
public override void Accept(ref TContainer container, IPropertyVisitor visitor) { var value = GetValue(ref container); if (false == visitor.ExcludeVisit(ref container, new VisitContext <TValue> { Property = this, Value = value, Index = -1 })) { var listContext = new VisitContext <TValue> { Property = this, Value = value, Index = -1 }; if (visitor.BeginList(ref container, listContext)) { var itemVisitContext = new VisitContext <TItem> { Property = this }; var count = Count(ref container); for (var i = 0; i < count; i++) { var item = GetItemAt(ref container, i); itemVisitContext.Value = item; itemVisitContext.Index = i; if (false == visitor.ExcludeVisit(ref container, itemVisitContext)) { if (visitor.BeginContainer(ref container, itemVisitContext)) { PropertyContainer.Visit(ref item, visitor); } visitor.EndContainer(ref container, itemVisitContext); } } } visitor.EndList(ref container, listContext); } }