Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
 public HashSet <Type> SupportedPrimitiveTypes()
 {
     return(OptimizedVisitor.SupportedTypes());
 }