本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例10: Spectrum
public Spectrum(double startRt, double endRt, IList<double> xValues, IList<double> yValues)
: base(xValues, yValues)
{
StartRT = startRt;
EndRT = endRt;
totalIntensity = yValues.Sum();
}
示例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);
}
示例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;
}
示例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()
};
});
}
示例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;
}
示例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);
}