Ejemplo n.º 1
0
        public object PostProcessReturnValue(object current, PropertySelectionContext ctx, PassengerConfiguration configuration)
        {
            if (current == null)
            {
                return(null);
            }

            var snapshotOfCollection = new List <object>();

            if (current.IsCollection())
            {
                snapshotOfCollection.AddRange(((IEnumerable)current).Cast <object>());
            }

            if (!ctx.IsPageComponent)
            {
                if (ctx.RawSelectedElement.IsAWebElement() &&
                    ctx.TargetProperty.PropertyType.IsAPassengerElement())
                {
                    current = TypeMapping.WrapIntoPassengerElement(ctx.RawSelectedElement, ctx.TargetProperty.PropertyType);
                }

                if (ctx.RawSelectedElement.IsCollection() &&
                    ctx.TargetProperty.PropertyType.IsCollection())
                {
                    current = TypeMapping.BuildCollectionOfWrappers(ctx.RawSelectedElement, ctx.TargetProperty.PropertyType, _configuration);
                }
            }

            if (current.IsAPassengerElement())
            {
                ((IPassengerElement)current).Inner = ctx.RawSelectedElement as IWebElement;
            }

            if (current.IsCollection())
            {
                MapSnapshotToInnerProperty(current, snapshotOfCollection);
            }

            return(current);
        }