Ejemplo n.º 1
0
        public IEnumerable <TransitiondataData> FindUserTransitionData()
        {
            //#TRANS01  9 10  6 4 6...

            var search = _fileContents
                         .Where(it => it.StartsWith("#"));

            var transitionsCollection = new Collection <TransitiondataData>();

            foreach (var data in search)
            {
                var elems = data
                            .Split(' ')
                            .Where(it => !string.IsNullOrWhiteSpace(it))
                            .Select(it => it)
                            .ToArray();

                var totalDirections = Int32.Parse(elems[1]); //not used ( = 9 )
                var numberOfPairs   = Int32.Parse(elems[2]);

                var newTransitionData = new TransitiondataData
                {
                    Name = elems[0],
                    Data = elems.Skip(3)
                           .SelectEven()
                           .Zip(elems.Skip(3).SelectOdd(),
                                (s1, s2) => new [] { Int32.Parse(s1), Int32.Parse(s2) })
                           .ToArray()
                };

                transitionsCollection.Add(newTransitionData);
            }

            return(transitionsCollection);
        }
Ejemplo n.º 2
0
        public IEnumerable<TransitiondataData> FindUserTransitionData()
        {
            //#TRANS01  9 10  6 4 6...

            var search = _fileContents
                .Where(it => it.StartsWith("#"));

            var transitionsCollection = new Collection<TransitiondataData>();

            foreach (var data in search)
            {
                var elems = data
                    .Split(' ')
                    .Where(it => !string.IsNullOrWhiteSpace(it))
                    .Select(it => it)
                    .ToArray();

                var totalDirections = Int32.Parse(elems[1]); //not used ( = 9 )
                var numberOfPairs = Int32.Parse(elems[2]);

                var newTransitionData = new TransitiondataData
                {
                    Name = elems[0],
                    Data = elems.Skip(3)
                        .SelectEven()
                        .Zip(elems.Skip(3).SelectOdd(),
                            (s1, s2) => new []{ Int32.Parse(s1), Int32.Parse(s2)})
                        .ToArray()
                };

                transitionsCollection.Add(newTransitionData);
            }

            return transitionsCollection;
        }