当前位置: 首页>>代码示例>>C#>>正文


C# IList.Sum方法代码示例

本文整理汇总了C#中IList.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Sum方法的具体用法?C# IList.Sum怎么用?C# IList.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IList的用法示例。


在下文中一共展示了IList.Sum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: loadReportBilancio

        private void loadReportBilancio(IList<ReportBilancioDTO> bilancioDataSource)
        {
            var importoTotale = 0m;

            reportViewer1.LocalReport.ReportEmbeddedResource = "Gipasoft.Stabili.UI.Bilanci.Reports.BilancioConsuntivoDettaglio.rdlc";
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReportBilancioDTO", getBilancioService().CloneReportBilancioDataSource(bilancioDataSource)));

            if (_bilancioDataSource != null)
            {
                _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                importoTotale = bilancioDataSource.Sum(item => item.ImportoSottoConto) + bilancioDataSource.Sum(item => item.ImportoMovimento);
                if (Security.Login.Instance.CurrentLogin().InversioneSaldiCondomini)
                {
                    importoTotale = importoTotale * -1;
                    _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                }
                
                importoTotale += _reportParameters.TotaleVersamenti;
                importoTotale += _reportParameters.SaldoPrecedente;
            }

            getReportParameters(importoTotale);

            // Add a handler for SubreportProcessing
            reportViewer1.LocalReport.SubreportProcessing += localReportSubreportProcessing;

            reportViewer1.LocalReport.SetParameters(getReportParameters(importoTotale));
            reportViewer1.RefreshReport();
        }
开发者ID:gipasoft,项目名称:Sfera,代码行数:29,代码来源:AnteprimaStampaDettaglio.cs

示例2: Update

        public void Update(ICacheService cacheService, Account selectedAccount, WorkPeriod currentWorkPeriod)
        {
            var accountType = cacheService.GetAccountTypeById(selectedAccount.AccountTypeId);
            var transactions = Dao.Query(GetCurrentRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod)).OrderBy(x => x.Date);
            Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
            if (accountType.DefaultFilterType > 0)
            {
                var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(accountType.DefaultFilterType, x => x.AccountId == selectedAccount.Id, currentWorkPeriod));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.Total, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Name = Resources.PastTransactions,
                            Credit = pastCredit,
                            Debit = pastDebit,
                            Exchange = pastExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Insert(0, detailValue);
                }
            }

            Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));

            for (var i = 0; i < Transactions.Count; i++)
            {
                Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
                if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
            }
        }
开发者ID:khriza,项目名称:SambaPOS-3,代码行数:34,代码来源:AccountTransactionSummary.cs

示例3: CalculateAverage

 public static CoreDataSet CalculateAverage(IList<CoreDataSet> validData)
 {
     var average = CoreDataSet.GetNullObject();
     average.Count = validData.Sum(x => x.Count.Value);
     average.Value = validData.Sum(x => x.Count).Value / validData.Count;
     return average;
 }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:7,代码来源:CountAverageCalculator.cs

示例4: loadReportBilancio

        private void loadReportBilancio(IList<ReportBilancioDTO> bilancioDataSource, CondominioDTO condominioDTO, EsercizioDTO esercizioDTO)
        {
            var importoTotale = 0m;

            reportViewer1.LocalReport.ReportEmbeddedResource = _reportParameters.TipoDettaglio == TipoDettaglioReportBilancio.Movimenti ? "Gipasoft.Stabili.UI.Bilanci.Reports.BilancioConsuntivo_Movimenti.rdlc" : "Gipasoft.Stabili.UI.Bilanci.Reports.BilancioConsuntivo_SottoConti.rdlc";
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReportBilancioDTO", _bilancioService.CloneReportBilancioDataSource(bilancioDataSource)));

            if (_bilancioDataSource != null)
            {
                _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                importoTotale = bilancioDataSource.Sum(item => item.ImportoSottoConto) + bilancioDataSource.Sum(item => item.ImportoMovimento);
                if (Login.Instance.CurrentLogin().InversioneSaldiCondomini)
                {
                    importoTotale = importoTotale * -1;
                    _reportParameters.TotaleVersamenti = _reportParameters.TotaleVersamenti*-1;
                }
                
                importoTotale += _reportParameters.TotaleVersamenti;
                importoTotale += _reportParameters.SaldoPrecedente;
            }

            getReportParameters(importoTotale, condominioDTO, esercizioDTO);

            reportViewer1.LocalReport.SetParameters(getReportParameters(importoTotale, condominioDTO, esercizioDTO));
            reportViewer1.RefreshReport();
        }
开发者ID:gipasoft,项目名称:Sfera,代码行数:26,代码来源:AnteprimaStampa.cs

示例5: Update

        public void Update(Account selectedAccount, DateTime? start, DateTime? end)
        {
            Start = start;
            End = end;
            var transactions = Dao.Query(GetCurrentRange(start, end, x => x.AccountId == selectedAccount.Id)).OrderBy(x => x.Date);
            Transactions = transactions.Select(x => new AccountDetailData(x, selectedAccount)).ToList();
            if (start.HasValue)
            {
                var pastDebit = Dao.Sum(x => x.Debit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                var pastCredit = Dao.Sum(x => x.Credit, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                var pastExchange = Dao.Sum(x => x.Exchange, GetPastRange(start, x => x.AccountId == selectedAccount.Id));
                if (pastCredit > 0 || pastDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.TransactionTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Date = start.GetValueOrDefault(),
                            Name = Resources.BalanceBroughtForward,
                            Credit = pastCredit,
                            Debit = pastDebit,
                            Exchange = pastExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Insert(0, detailValue);
                }
            }
            if (end.HasValue && end != start)
            {
                var futureDebit = Dao.Sum(x => x.Debit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                var futureCredit = Dao.Sum(x => x.Credit, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                var futureExchange = Dao.Sum(x => x.Exchange, GetFutureRange(end, x => x.AccountId == selectedAccount.Id));
                if (futureCredit > 0 || futureDebit > 0)
                {
                    Summaries.Add(new AccountSummaryData(Resources.DateRangeTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));
                    var detailValue =
                        new AccountDetailData(
                        new AccountTransactionValue
                        {
                            Date = end.GetValueOrDefault(),
                            Name = Resources.BalanceAfterDate,
                            Credit = futureCredit,
                            Debit = futureDebit,
                            Exchange = futureExchange
                        }, selectedAccount) { IsBold = true };
                    Transactions.Add(detailValue);
                }
            }

            Summaries.Add(new AccountSummaryData(Resources.GrandTotal, Transactions.Sum(x => x.Debit), Transactions.Sum(x => x.Credit)));

            for (var i = 0; i < Transactions.Count; i++)
            {
                Transactions[i].Balance = (Transactions[i].Debit - Transactions[i].Credit);
                if (i > 0) (Transactions[i].Balance) += (Transactions[i - 1].Balance);
            }
        }
开发者ID:jgera,项目名称:SambaPOS-3,代码行数:57,代码来源:AccountTransactionSummary.cs

示例6: Calculate

        public double Calculate(IList<Coder> participants)
        {
            var n = participants.Count;
            var ratAvg = participants.Average(x => x.R);

            var sqrRatStdev = participants.Sum(x => Math.Pow(x.R - ratAvg, 2)) / (n - 1);
            var sqrVolAvg = participants.Sum(x => x.V * x.V) / n;

            return Math.Sqrt(sqrVolAvg + sqrRatStdev);
        }
开发者ID:IvanMacek,项目名称:TopCoder-Rating-Analysis,代码行数:10,代码来源:CompetitionFactorFunction.cs

示例7: CalculateAverage

        public static CoreDataSet CalculateAverage(IList<CoreDataSet> validData, Unit unit)
        {
            var average = CoreDataSet.GetNullObject();
            average.Count = validData.Sum(x => x.Count.Value);
            average.Denominator = validData.Sum(x => x.Denominator);
            average.Value = (average.Count.Value / average.Denominator) * unit.Value;

            average.ValueNoteId = ValueNoteIds.ValueAggregatedFromAllKnownGeographyValues;
            return average;
        }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:10,代码来源:WeightedAverageCalculator.cs

示例8: ForPeriod

    private static StatisticsForPeriod ForPeriod(IList<FocusSession> sessions, string periodName)
    {
        var result = new StatisticsForPeriod
        {
            PeriodName = periodName,
            FocusMinutes = sessions.Sum(x => x.WasInterrupted ? - x.Minutes : x.Minutes),
            TotalMinutes = sessions.Sum(x => x.Minutes),
            InterruptionCount = sessions.Count(x => x.WasInterrupted),
            InterruptionMinutes = sessions.Where(x => x.WasInterrupted).Sum(x => x.Minutes),
            SessionCount = sessions.Count
        };

        return result;
    }
开发者ID:RobertMischke,项目名称:Start-Focus,代码行数:14,代码来源:GetStatistics.cs

示例9: OrderLine

        public OrderLine(Product product, int quantity, IList<Outcome> outcomes):this()
        {
            Product = product;
            Quantity = quantity;
            Price = product.Price;
            ProductName = product.Name;

            Outcomes = outcomes;
            outcomes.ForEach(x => x.OrderLine = this);

            Profit = Outcomes.Sum(outcome => outcome.Profit);
            SummWithDiscount = Outcomes.Sum(outcome => outcome.SummWithDiscount);

        }
开发者ID:Phidel,项目名称:elfam,代码行数:14,代码来源:OrderLine.cs

示例10: Spectrum

 public Spectrum(double startRt, double endRt, IList<double> xValues, IList<double> yValues)
     : base(xValues, yValues)
 {
     StartRT = startRt;
     EndRT = endRt;
     totalIntensity = yValues.Sum();
 }
开发者ID:pol,项目名称:MassSpecStudio,代码行数:7,代码来源:Spectrum.cs

示例11: ApproximateLine

        public static LineEquation ApproximateLine(IList<double> values)
        {
            double sumX = 0;
            for (int i = 0; i < values.Count; ++i)
            {
                sumX += i;
            }

            int n = values.Count;
            double ssXX = 0;
            double ssYY = 0;
            double ssXY = 0;
            double meanX = sumX / n;
            double meanY = values.Sum() / n;
            for (int i = 0; i < values.Count; ++i)
            {
                ssXX += (double)Math.Pow(i - meanX, 2);
                ssYY += (double)Math.Pow(values[i] - meanY, 2);
                ssXY += (i - meanX)*(values[i] - meanY);
            }

            double b = ssXY / ssXX;
            double a = meanY - b * meanX;

            return new LineEquation(a, b);
        }
开发者ID:philllies,项目名称:finalproject,代码行数:26,代码来源:MathUtil.cs

示例12: CalculateUpdatedTeamMoney

        public static int CalculateUpdatedTeamMoney(IList<Transfer> transfers, int currentMoney)
        {
            //process transfers as a whole
            int totalMoneySpent = transfers.Sum(t => t.PlayerIn.NowCost);

            int totalMoneyIn = 0;
            foreach (var transfer in transfers)
            {
                if (transfer.PlayerOut.NowCost <= transfer.PlayerOut.OriginalCost)
                {
                    totalMoneyIn += transfer.PlayerOut.NowCost;
                }
                else
                {
                    var difference = transfer.PlayerOut.NowCost - transfer.PlayerOut.OriginalCost;

                    //you get 50% of the difference, rounded down to nearest 0.1 mllion
                    totalMoneyIn += transfer.PlayerOut.OriginalCost + (difference / 2);
                }
            }

            var newMoneyValue = currentMoney - totalMoneySpent + totalMoneyIn;

            return newMoneyValue;
        }
开发者ID:robinweston,项目名称:fantasyfootballrobot,代码行数:25,代码来源:CommonTransferFunctions.cs

示例13: Calculate

      public async Task<IssuesCollectionStatistics> Calculate(IList<JiraIssue> issues)
      {
         if(issues == null || issues.Any() == false)
            return null;

         return await Task.Factory.StartNew(() =>
         {
            return new IssuesCollectionStatistics
            {
               IssuesCount = issues.Count(),
               ResolvedIssuesCount = issues.Where(i => i.Resolved.HasValue).Count(),
               UnresolvedIssuesCount = issues.Where(i => i.Resolved.HasValue == false).Count(),

               AverageResolutionTimeHours = issues
                                               .Where(i => i.Resolved.HasValue)
                                               .Select(i => (i.Resolved.Value - i.Created).TotalHours).Average(),
               MaxResolutionTimeHours = issues
                                               .Where(i => i.Resolved.HasValue)
                                               .Select(i => (i.Resolved.Value - i.Created).TotalHours).Max(),

               TotalStorypoints = issues.Sum(i => i.StoryPoints),
               AverageStorypointsPerTask = issues.Average(i => i.StoryPoints),

               AverageSubtasksCount = issues.Average(i => i.Subtasks),

               EpicsInvolved = issues.Select(i => i.EpicLink).Distinct().Count(),

               DistinctReporters = issues.Select(i => i.Reporter).Distinct().Count()
            };
         });
      }
开发者ID:sceeter89,项目名称:jira-client,代码行数:31,代码来源:IssuesStatisticsCalculator.cs

示例14: NumericRange

 public NumericRange(IList<double> values)
 {
     double num3;
     double num4;
     double current;
     Func<double, double> selector = null;
     double num = 0.0;
     double num2 = 0.0;
     goto Label_016A;
     Label_00F1:
     using (IEnumerator<double> enumerator = values.GetEnumerator())
     {
         goto Label_011B;
     Label_00FB:
         if ((((uint) current) - ((uint) num)) > uint.MaxValue)
         {
             goto Label_0142;
         }
         num4 += current * current;
     Label_011B:
         if (!enumerator.MoveNext())
         {
             goto Label_0157;
         }
         current = enumerator.Current;
         num = Math.Max(num, current);
         num2 = Math.Min(num2, current);
     Label_0142:
         num3 += current;
         goto Label_00FB;
     }
     Label_0157:
     this._xdc8f3f8857bee4c6 = values.Count;
     this._x628ea9b89457a2a9 = num;
     this._xd12d1dba8a023d95 = num2;
     this._x0eb49ee242305597 = num3 / ((double) this._xdc8f3f8857bee4c6);
     this._xcce91100698a4514 = Math.Sqrt(num4 / ((double) this._xdc8f3f8857bee4c6));
     if (((((uint) num2) & 0) != 0) || ((((uint) num2) + ((uint) current)) >= 0))
     {
         if (selector == null)
         {
             selector = new Func<double, double>(this, (IntPtr) this.xf29670e286f5562f);
         }
         double num6 = values.Sum<double>(selector);
         this._x8db8a12c7e795fea = Math.Sqrt(num6 / ((double) this._xdc8f3f8857bee4c6));
         if ((((uint) current) + ((uint) num4)) > uint.MaxValue)
         {
             goto Label_00F1;
         }
         if ((((uint) num6) - ((uint) current)) <= uint.MaxValue)
         {
             return;
         }
     }
     Label_016A:
     num3 = 0.0;
     num4 = 0.0;
     goto Label_00F1;
 }
开发者ID:neismit,项目名称:emds,代码行数:59,代码来源:NumericRange.cs

示例15: FindSumAndAverage

        private static void FindSumAndAverage(IList<int> numbers)
        {
            long numbersSum = 0;
            double numbersAverage = 0;

            numbersSum = numbers.Sum();
            numbersAverage = numbers.Average();
            Console.WriteLine("The sum of your sequence is: {0} and the avgerage is: {1}.", numbersSum, numbersAverage);
        }
开发者ID:ekostadinov,项目名称:CoursesProjects,代码行数:9,代码来源:PositiveIntegersSequence.cs


注:本文中的IList.Sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。