Пример #1
0
        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
                };

                for (var i = 0; i < Count(ref container); i++)
                {
                    var item = GetAt(ref container, i);

                    itemVisitContext.Value = item;
                    itemVisitContext.Index = i;

                    if (false == visitor.ExcludeOrCustomVisit(ref container, itemVisitContext))
                    {
                        visitor.Visit(ref container, itemVisitContext);
                    }
                }
            }
            visitor.EndCollection(ref container, listContext);
        }
        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);
        }
Пример #3
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);
            }
Пример #4
0
                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);
                }
Пример #5
0
                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);
                }
Пример #6
0
        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);
        }
Пример #7
0
                public override void Accept(MigrationContainer container, IPropertyVisitor visitor)
                {
                    var list = GetList(container);

                    var listContext = new VisitContext <IList <TItem> >
                    {
                        Property = this,
                        Value    = list,
                        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++)
                        {
                            itemVisitContext.Value = TypeConversion.Convert <TItem>(list[i]);
                            itemVisitContext.Index = i;

                            if (false == visitor.ExcludeOrCustomVisit(container, itemVisitContext))
                            {
                                visitor.Visit(container, itemVisitContext);
                            }
                        }
                    }

                    visitor.EndCollection(container, listContext);
                }
Пример #8
0
        public override void Accept(TContainer container, IPropertyVisitor visitor)
        {
            var set = GetHashSet(container);

            if (visitor.ExcludeVisit(container, new VisitContext <HashSet <TItem> > {
                Property = this, Value = set, Index = -1
            }))
            {
                return;
            }

            var setContext = new VisitContext <HashSet <TItem> > {
                Property = this, Value = set, Index = -1
            };

            if (visitor.BeginCollection(container, setContext))
            {
                var itemVisitContext = new VisitContext <TItem>
                {
                    Property = this
                };

                var index = -1;
                foreach (var item in set)
                {
                    itemVisitContext.Value = item;
                    itemVisitContext.Index = ++index;

                    if (false == visitor.ExcludeVisit(container, itemVisitContext))
                    {
                        visitor.Visit(container, itemVisitContext);
                    }
                }
            }
            visitor.EndCollection(container, setContext);
        }