コード例 #1
0
ファイル: Statistic.cs プロジェクト: nicolaslarsen/evd-test
        public List <StatisticProperty> BuildStats()
        {
            List <StatisticProperty> statList = new List <StatisticProperty>();


            foreach (Evalue Ejendom in FirstFile.Evalues)
            {
                Evalue            scndEjd  = SecondFile.GetProperty(Ejendom.KomNr, Ejendom.EjdNr);
                StatisticProperty statProp = CompareProperties(Ejendom, scndEjd);
                if (statProp != null)
                {
                    statList.Add(statProp);
                }
            }

            return(statList);
        }
コード例 #2
0
        public static string BuildOutputString(EvalueStorage firstFile, EvalueStorage secondFile)
        {
            // Just get the header from a new instance
            string output = new T().Header();

            Random     rand    = new Random();
            List <int> randoms = new List <int>();

            int i = 0;

            // randoms < firstFile and secondFile to make sure we have enough properties to test.
            while (i < 5 && randoms.Count() < firstFile.Length() &&
                   randoms.Count() < secondFile.Length())
            {
                int randIndex = rand.Next(secondFile.Length());

                // If we already used this property
                if (randoms.Contains(randIndex))
                {
                    continue;
                }
                // we should probably get the second ejendom first,
                // since this one is filtered
                Evalue secondEjendom = secondFile.Evalues[randIndex];

                Evalue firstEjendom = firstFile.GetProperty(
                    secondEjendom.KomNr, secondEjendom.EjdNr);

                // If secondFile did not contain the property
                if (firstEjendom == null)
                {
                    continue;
                }
                output += firstEjendom.ToCsv() + "\n" + secondEjendom.ToCsv() + "\n\n";

                randoms.Add(randIndex);
                i++;
            }

            // Only get properties that are "i udbud"
            List <Evalue> ScndIUdbud = secondFile.Evalues.Where(ejd => ejd.ErIUdbud == 1).ToList();

            // Just force it to 5, so we only get 5 where ErIUdbud == 1
            if (i != 5)
            {
                i = 5;
            }

            // i should be 5 at this point, so we get 5 more properties here
            while (i < 10 && randoms.Count() < ScndIUdbud.Count())
            {
                int randIndex = rand.Next(ScndIUdbud.Count);

                // If we already used this property we skip it
                // (we haven't necessarily used it, but chances are,
                // that this case won't be hit a lot anyway)
                if (randoms.Contains(randIndex))
                {
                    continue;
                }
                Evalue Ejendom = ScndIUdbud[randIndex];

                output += Ejendom.ToCsv() + "\n";

                randoms.Add(randIndex);
                i++;
            }
            return(output);
        }