Imports System.Globalization Public Class Sheet Public Shared Sheets As New Dictionary(Of Integer, Sheet) Private Property Sheet As Integer Public Property Members As List(Of Member) Public Sub New(sheet As Integer) Members = New List(Of Member) Me.Sheet = sheet End Sub ''' <summary> ''' Generates the total weight of a sheet when the type of member ''' is passed to the function ''' </summary> ''' <param name="memberType">The type of member on a sheet, i.e. "Ladder", "Stair", etc</param> ''' <returns>Returns as a double the total weight of all members on a sheet for the MemberType</returns> ''' <remarks></remarks> Public Shared Function WeightByType(memberType As String) As Decimal Dim subset = Sheets.Where( Function(kvp As KeyValuePair(Of Integer, Sheet)) _ kvp.Value.Members.Count(Function(m) m.MemberType = memberType) > 0) subset.ToList().ForEach( Sub(kvp As KeyValuePair(Of Integer, Sheet)) _ WeightByType += (kvp.Value.Members.Sum( Function(m As Member) _ Convert.ToDecimal(m.TotalWeight, CultureInfo.InvariantCulture)))) End Function End Class
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
4 Experts available now in Live!