本文整理汇总了C#中ReadOnlyCollection.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.Sum方法的具体用法?C# ReadOnlyCollection.Sum怎么用?C# ReadOnlyCollection.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.Sum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IpV6MobilityOptionContextRequest
/// <summary>
/// Creates an instance from a collection of requests.
/// </summary>
/// <param name="requests">The requests types and options.</param>
public IpV6MobilityOptionContextRequest(ReadOnlyCollection<IpV6MobilityOptionContextRequestEntry> requests)
: base(IpV6MobilityOptionType.ContextRequest)
{
Requests = requests;
_dataLength = OptionDataMinimumLength + Requests.Sum(request => request.Length);
if (_dataLength > byte.MaxValue)
throw new ArgumentOutOfRangeException("requests", requests,
string.Format(CultureInfo.InvariantCulture, "requests length is too large. Takes over {0}>{1} bytes.",
_dataLength, byte.MaxValue));
}
示例2: StatementAccount
internal StatementAccount(StatementInfo parent, string accountName)
{
Parent = parent;
AccountName = accountName;
OutstandingBalance = Parent.Person.GetBalance(Parent.StartDate, AccountName);
BalanceDue = Math.Max(0, Parent.Person.GetBalance(AccountName));
Func<ITransaction, bool> filter = t => t.Date >= Parent.StartDate && t.Date < Parent.EndDate && t.Account == AccountName;
Pledges = new ReadOnlyCollection<Pledge>(Parent.Person.Pledges.Where(p => filter(p)).OrderBy(p => p.Date).ToArray());
Payments = new ReadOnlyCollection<Payment>(Parent.Person.Payments.Where(p => filter(p)).OrderBy(p => p.Date).ToArray());
TotalPledged = OutstandingBalance + Pledges.Sum(p => p.Amount);
TotalPaid = Payments.Sum(p => p.Amount);
}
示例3: StrokeMatch
public StrokeMatch(IEnumerable<StrokePartMatch> parts)
{
Parts = new ReadOnlyCollection<StrokePartMatch>(parts.ToArray());
Cost = Parts.Sum(p => p.MinCost);
//Cost = Parts.Count * (Cost + 0.001f *parts.Sum(p=>p.Delta.LengthSquared));
}
示例4: Recalculate
public void Recalculate()
{
if (Person.Schema.Columns.Contains("BalanceDue"))
TotalBalance = Math.Max(0, Person.Field<decimal>("BalanceDue"));
else
TotalBalance = Person.Pledges.Concat<ITransaction>(Person.Payments).Sum(t => t.SignedAmount);
Accounts = new ReadOnlyCollection<StatementAccount>(
Names.AccountNames.Select(a => new StatementAccount(this, a))
.Where(ba => ba.ShouldInclude)
.ToArray()
);
TotalPledged = Accounts.Sum(a => a.TotalPledged);
TotalPaid = Accounts.Sum(a => a.TotalPaid);
Deductibility = String.Join(" ", CalcDeductibility());
if (data.Table<Payment>().Rows.Any())
LastEnteredPayment = data.Table<Payment>().Rows.Max(p => p.Modified);
else if (data.Table<Pledge>().Rows.Any())
LastEnteredPayment = data.Table<Pledge>().Rows.Max(p => p.Modified);
else
LastEnteredPayment = new DateTime(1970, 1, 1);
}