示例#1
0
        List <Element> getColumns(int i)
        {
            List <Element> cols = new List <Element>();

            Item     item_   = dFactory.Items[i];
            ItemDB   db_     = dFactory.ItemDBs[i];
            ItemInfo info_   = dFactory.ItemInfos[i];
            int      cityNo_ = item_.cityNo - 1;
            City     city_   = dFactory.Cities[cityNo_];
            int      firmNo_ = item_.firmNo;

            finder <Firm> finder = (firms, index) => {
                // Firm result = firms.FirstOrDefault(x => x.firmNo == index);

                Firm result = firms.SingleOrDefault(x => x.firmNo == index);

                return(result);
            };

            Firm firm_ = finder(dFactory.Firms, firmNo_);
            int  groupNo_;

            if (firm_ == null)
            {
                groupNo_ = 0;
            }
            else
            {
                groupNo_ = firm_.groupNo - 1;
            }
            Group group_ = dFactory.Groups[groupNo_];

            cols.Add(item_.ItemAddress);
            cols.Add(item_.ItemID);
            cols.Add(db_.Name);
            cols.Add(db_.Address);
            cols.Add(info_.Address);
            cols.Add(item_.FirmNo);
            cols.Add(city_.Name);
            cols.Add(group_.Name);

            return(cols);
        }
示例#2
0
        static void Test(finder f, double[] array, int length, string name)
        {
            Stopwatch timer = Stopwatch.StartNew();

            timer.Start();
            var result = f(array, length);

            timer.Stop();

            if (result == -1)
            {
                Console.WriteLine("{0} array does not contain positive elements!", name);
            }
            else
            {
                Console.WriteLine("{0} average of positive: {1:F5}", name, result);
            }

            Console.WriteLine("{0} time: {1} ms", name, timer.ElapsedMilliseconds);
        }