예제 #1
0
        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);
            }
        }
예제 #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);
            }
        }
예제 #3
0
        private static IReadOnlyState CreateNestedState(object obj, NestedTypeConfiguration ntc, IReadOnlyState state)
        {
            if (ntc?.AddState == null)
            {
                return(state);
            }

            var addedState = new State();

            ntc.AddState(obj, state, addedState);
            var newState = new State(state, addedState);

            return(new ReadOnlyState(newState));
        }
예제 #4
0
 private void CopyAndAugmentObject(object obj, List <TypeConfiguration> typeConfigurations, AObject root, IReadOnlyState state, NestedTypeConfiguration ntc, object parentForNested)
 {
     foreach (var typeConfiguration in typeConfigurations)
     {
         if (ntc != null)
         {
             state = CreateNestedState(parentForNested, ntc, state);
         }
         CopyObject(obj, typeConfiguration, root, state);
     }
     foreach (var typeConfiguration in typeConfigurations)
     {
         if (ntc != null)
         {
             state = CreateNestedState(parentForNested, ntc, state);
         }
         AugmentObject(obj, typeConfiguration, root, state);
     }
 }