private void AugmentArray(
            object obj,
            NestedTypeConfiguration ntc,
            object arr,
            APropertyInfo property,
            AArray nestedList,
            IReadOnlyState state,
            List <TypeConfiguration> tcs)
        {
            var asEnumerable = arr as IEnumerable;

            Debug.Assert(asEnumerable != null, "asEnumerable != null");
            foreach (var item in asEnumerable)
            {
                var actual = item;
                if (property.TypeInfoWrapper.IsWrapper)
                {
                    if (item is AugmenterWrapper wrapper)
                    {
                        actual = wrapper.Object;
                    }
                }

                var dict = new AObject();
                CopyAndAugmentObject(actual, tcs, dict, state, ntc, obj);
                nestedList.Add(dict);
            }
        }
Example #2
0
        private void AugmentArray(
            object obj,
            NestedTypeConfiguration ntc,
            object arr,
            APropertyInfo property,
            AArray nestedList,
            IReadOnlyState state,
            List <TypeConfiguration> typeConfigurations)
        {
            var asEnumerable = arr as IEnumerable;

            Debug.Assert(asEnumerable != null, "asEnumerable != null");
            foreach (var item in asEnumerable)
            {
                var actual = item;
                if (property.TypeInfoWrapper.IsWrapper)
                {
                    if (item is AugmenterWrapper wrapper)
                    {
                        actual = wrapper.Object;
                    }
                }

                var dict = new AObject();
                // ReSharper disable once ForCanBeConvertedToForeach
                for (var i = 0; i < typeConfigurations.Count; i++)
                {
                    var tc          = typeConfigurations[i];
                    var nestedState = CreateNestedState(obj, ntc, state);
                    AugmentObject(actual, tc, dict, nestedState);
                }
                nestedList.Add(dict);
            }
        }
        private static NestedTypeConfiguration GetNestedTypeConfiguration(
            TypeConfiguration typeConfiguration, APropertyInfo property)
        {
            if (!typeConfiguration.NestedConfigurations.IsValueCreated)
            {
                return(null);
            }

            if (!typeConfiguration.NestedConfigurations.Value.TryGetValue(
                    property.PropertyInfo, out var ntc))
            {
                return(null);
            }

            return(ntc);
        }