Exemple #1
0
        public List<IOutData> ProcessData(IReadOnlyList<IInData> inputData)
        {
          
            List<ResultRegistr> resultData = new List<ResultRegistr>();
            List<int> codeCollestions=new List<int>();
            int indexList;
            
            foreach(IInData element in inputData)
            {
                if (element.IsValid)
                {
                    if (!codeCollestions.Contains(element.Code))
                    {
                        codeCollestions.Add(element.Code);
                        ResultRegistr rr = new ResultRegistr(element.Code, element.Value, 1);
                        resultData.Add(rr);
                    }
                    else
                    {
                        indexList = resultData.FindIndex(elementCode => elementCode.code == element.Code);
                        resultData[indexList].value += element.Value;
                        resultData[indexList].countOfData++;
                    }
                }

            }
            List<OutData> listRezult = new List<OutData>();
            for (int i = 0; i < resultData.Count; i++)
            {

                listRezult.Add(new OutData ( resultData[i].code, resultData[i].value / resultData[i].countOfData ));
               
            }

           //В этой строке невозможно преобразовать список
           List<IOutData> result = listRezult.ConvertAll( new Converter<OutData,IOutData>(MyConverter));
          
            return result;
        }
Exemple #2
0
        public List<IOutData> ProcessData(IReadOnlyList<IInData> inputData)
        {
            List<ResultRegistr> resultData = new List<ResultRegistr>();
            List<int> codeCollestions=new List<int>();
            int indexList;

            foreach(IInData element in inputData)
            {
                if (element.IsValid)
                {
                    if (!codeCollestions.Contains(element.Code))
                    {
                        codeCollestions.Add(element.Code);
                        ResultRegistr rr = new ResultRegistr(element.Code, element.Value, 1);
                        resultData.Add(rr);
                    }
                    else
                    {
                        indexList = resultData.FindIndex(elementCode => elementCode.code == element.Code);
                        resultData[indexList].value += element.Value;
                        resultData[indexList].countOfData++;
                    }
                }

            }
            List<OutData> listRezult = new List<OutData>();
            for (int i = 0; i < resultData.Count; i++)
            {

                listRezult.Add(new OutData ( resultData[i].code, resultData[i].value / resultData[i].countOfData ));

            }

               //В этой строке невозможно преобразовать список
               List<IOutData> result = listRezult.ConvertAll( new Converter<OutData,IOutData>(MyConverter));

            return result;
        }