private static IEnumerable <Expression> GetArrays(Type rootType, Expression path, IEnumerable <MutatorConfiguration> mutators)
        {
            var arrays          = new List <Dictionary <Type, List <Expression> > >();
            var arraysExtractor = new ArraysExtractor(arrays);

            arraysExtractor.GetArrays(path);
            foreach (var mutator in mutators)
            {
                mutator.GetArrays(arraysExtractor);
            }
            var result = new List <Expression>();

            for (var i = 1; i < arrays.Count; ++i)
            {
                var dict = arrays[i];
                if (dict.Count > 1)
                {
                    throw new InvalidOperationException("Too many root types");
                }
                if (!dict.TryGetValue(rootType, out var list))
                {
                    throw new InvalidOperationException("Invalid root type");
                }
                var arraysOfCurrentLevel = list.GroupBy(exp => new ExpressionWrapper(exp.ReplaceCurrentWithEach(), false)).Select(grouping => grouping.First()).ToArray();
                if (arraysOfCurrentLevel.Length > 1)
                {
                    throw new NotSupportedException("Iteration over more than one array is not supported");
                }
                result.Add(arraysOfCurrentLevel[0]);
            }

            return(result);
        }
 public override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(SourceArray);
 }
 internal override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(Condition);
     arraysExtractor.GetArrays(Path);
     arraysExtractor.GetArrays(Message);
 }
Exemplo n.º 4
0
 public override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(Condition);
 }
 public override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(Condition);
     arraysExtractor.GetArrays(validatorFromRoot);
 }
 internal override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(Condition);
 }
 public override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(Value);
 }
Exemplo n.º 8
0
 internal override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(Value);
 }
 internal override void GetArrays(ArraysExtractor arraysExtractor)
 {
     arraysExtractor.GetArrays(SourceArray);
 }