Implement Create method of FilterItem class using LINQ.
Create method takes a list of decimal numbers that is aggregated into ranges and scales.
There are three ranges: positive, negative and zero; positive range includes all positive numbers, etc.
Scales are multiples of 10, for example, 17300 belong to 10000 or 10^4 scale, 1250000 belongs to 1000000
or 10^6, 1350 belong to 1000 scale or 10^3, etc
For example, for this input { 17000, 35000, 120000, 0, 0, -15000, -1000000, -15000 }
the output looks like this on the wire, when FilterItem class is serialized to XML by a web service:
<FilterItem Text="All Items" Value="" Count="8">
<SubFilterItems>
<FilterItem Text="Range" Value="(+) Positive" Count="3">
<SubFilterItems>
<FilterItem Text="Scale" Value="10,000" Count="2"/>
<FilterItem Text="Scale" Value="100,000" Count="2"/>
</SubFilterItems>
</FilterItem>
<FilterItem Text="Range" Value="(0) Zero" Count="2"/>
<FilterItem Text="Range" Value="(-) Negative" Count="3">
<SubFilterItems>
<FilterItem Text="Scale" Value="-10,000" Count="1"/>
<FilterItem Text="Scale" Value="-100,000" Count="1"/>
<FilterItem Text="Scale" Value="-1,000,000" Count="1"/>
</SubFilterItems>
</FilterItem>
</SubFilterItems>
</FilterItem>
class Service
{
public FilterItem Aggregate(decimal[] items)
{
return FilterItem.Create(items.ToList());
}
}
class FilterItem
{
public static FilterItem Create(List<decimal> items)
{
}
public string Text { get; set; }
public string Value { get; set; }
public int Count { get; set; }
public List<FilterItem> SubFilterItems { get; set; }
}