public override void Accept(TContainer container, IPropertyVisitor visitor) { var listContext = new VisitContext <TItem> { Property = this, Index = -1 }; if (visitor.BeginCollection(container, listContext)) { var itemVisitContext = new VisitContext <TItem> { Property = this }; var count = Count(container); for (var i = 0; i < count; i++) { var item = GetAt(container, i); itemVisitContext.Value = item; itemVisitContext.Index = i; if (visitor.ExcludeVisit(container, itemVisitContext)) { continue; } if (visitor.BeginContainer(container, itemVisitContext)) { item?.Visit(visitor); } visitor.EndContainer(container, itemVisitContext); } } visitor.EndCollection(container, listContext); }
public override void Accept(ref EntityContainer container, IPropertyVisitor visitor) { var count = Count(container); var listContext = new VisitContext <IList <StructProxy> > { Property = this, Value = null, Index = -1 }; // @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.BeginCollection(ref container, listContext)) { for (var i = 0; i < count; i++) { StructProxy item; if (!Get(ref container, i, primitiveTypes, out item)) { continue; } var context = new VisitContext <StructProxy> { Property = this, Value = item, Index = i }; if (visitor.BeginContainer(ref container, context)) { (item.PropertyBag as StructPropertyBag <StructProxy>)?.Visit(ref item, visitor); } visitor.EndContainer(ref container, context); } } visitor.EndCollection(ref container, listContext); }
public override void Accept(ref TContainer container, IPropertyVisitor visitor) { var value = GetValue(ref container); var context = new VisitContext <TValue> { Property = this, Value = value, Index = -1 }; if (false == visitor.ExcludeVisit(ref container, context)) { if (visitor.BeginContainer(ref container, context)) { PropertyContainer.Visit(ref container, visitor); } visitor.EndContainer(ref container, context); } }
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(ObjectContainer container, IPropertyVisitor visitor) { var list = GetList(container); var listContext = new VisitContext <IList <ObjectContainer> > { Property = this, Value = list, Index = -1 }; if (visitor.ExcludeOrCustomVisit(container, listContext)) { return; } if (visitor.BeginCollection(container, listContext)) { var itemVisitContext = new VisitContext <ObjectContainer> { Property = this }; for (var i = 0; i < Count(container); i++) { var item = list?[i]; itemVisitContext.Value = item; itemVisitContext.Index = i; if (visitor.ExcludeOrCustomVisit(container, itemVisitContext)) { continue; } if (visitor.BeginContainer(container, itemVisitContext)) { item.Visit(visitor); } visitor.EndContainer(container, itemVisitContext); } } visitor.EndCollection(container, listContext); }
public override void Accept(ref TContainer container, IPropertyVisitor visitor) { var value = GetValue(container); var context = new VisitContext <TValue> { Property = this, Value = value, Index = -1 }; if (visitor.ExcludeOrCustomVisit(ref container, context)) { return; } if (visitor.BeginContainer(ref container, context)) { value?.Visit(visitor); } visitor.EndContainer(ref container, context); }
public override void Accept(MigrationContainer container, IPropertyVisitor visitor) { var listContext = new VisitContext <IList <TItem> > { Property = this, Value = null, Index = -1 }; if (visitor.ExcludeOrCustomVisit(container, listContext)) { return; } if (visitor.BeginCollection(container, listContext)) { var itemVisitContext = new VisitContext <TItem> { Property = this }; for (var i = 0; i < Count(container); i++) { var item = GetAt(container, i); itemVisitContext.Value = item; itemVisitContext.Index = i; if (visitor.ExcludeOrCustomVisit(container, itemVisitContext)) { continue; } if (visitor.BeginContainer(container, itemVisitContext)) { item?.Visit(visitor); } visitor.EndContainer(container, itemVisitContext); } } visitor.EndCollection(container, listContext); }
public override void Accept(ref StructProxy container, IPropertyVisitor visitor) { var listContext = new VisitContext <StructProxy> { Property = this, Index = -1 }; if (visitor.BeginCollection(ref container, listContext)) { var itemVisitContext = new VisitContext <StructProxy> { Property = this }; var count = Count(container); for (var i = 0; i < count; i++) { if (i >= MaxItemCountShown) { // TODO should instrument the visitor to be informed about the enumeration stop break; } var item = GetAt(ref container, i); itemVisitContext.Value = item; itemVisitContext.Index = i; if (visitor.ExcludeVisit(ref container, itemVisitContext)) { continue; } if (visitor.BeginContainer(ref container, itemVisitContext)) { PropertyContainer.Visit(ref item, visitor); } visitor.EndContainer(ref container, itemVisitContext); } } visitor.EndCollection(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); } }
public override void Accept(ref TContainer container, IPropertyVisitor visitor) { var listContext = new VisitContext <IList <TItem> > { Property = this, Index = -1, Value = GetList(ref container) }; if (visitor.ExcludeOrCustomVisit(ref container, listContext)) { return; } if (visitor.BeginCollection(ref container, listContext)) { var itemVisitContext = new VisitContext <TItem> { Property = this }; var count = Count(container); for (var i = 0; i < count; i++) { var item = GetAt(ref container, i); itemVisitContext.Value = item; itemVisitContext.Index = i; if (visitor.ExcludeOrCustomVisit(ref container, itemVisitContext)) { continue; } if (visitor.BeginContainer(ref container, itemVisitContext)) { PropertyContainer.Visit(ref item, visitor); } visitor.EndContainer(ref container, itemVisitContext); } } visitor.EndCollection(ref container, listContext); }
public override void Accept(MigrationContainer container, IPropertyVisitor visitor) { var value = GetObjectValue(container) as IPropertyContainer; var context = new VisitContext <IPropertyContainer> { Property = this, Value = value, Index = -1 }; if (visitor.ExcludeOrCustomVisit(container, context)) { return; } if (visitor.BeginContainer(container, context)) { value?.Visit(visitor); } visitor.EndContainer(container, context); }
public override void Accept(ObjectContainer container, IPropertyVisitor visitor) { var value = GetValue(container); var context = new VisitContext <ObjectContainer> { Property = this, Value = value, Index = -1 }; if (visitor.ExcludeVisit(container, context)) { return; } if (visitor.BeginContainer(container, context)) { value.Visit(visitor); } visitor.EndContainer(container, context); }
public override void Accept(ref TContainer container, IPropertyVisitor visitor) { var value = GetValue(ref container); var context = new VisitContext <TValue> { Property = this, Value = value, Index = -1 }; if (false == visitor.ExcludeVisit(ref container, context)) { if (visitor.BeginContainer(ref container, context)) { if (RefAccess == null) { // TODO: throw in read-write scenarios RefVisit(ref value, visitor); } else { RefAccess(ref container, RefVisit, visitor); } } visitor.EndContainer(ref container, context); } }