Skip to content

Instantly share code, notes, and snippets.

@grumpycatsaysno
Created January 28, 2016 08:14
Show Gist options
  • Save grumpycatsaysno/6bd439729a21bb32bc1b to your computer and use it in GitHub Desktop.
Save grumpycatsaysno/6bd439729a21bb32bc1b to your computer and use it in GitHub Desktop.
CustomPrepareData
private List<CustomTaxonData> CustomPrepareData(IDictionary<ITaxon, uint> taxaCount)
{
double num;
if (taxaCount.Count == 0)
{
return new List<CustomTaxonData>();
}
List<double> list = (
from pair in taxaCount
select pair.Value into t
select (double)((float)t)).ToList<double>();
double num1 = this.StandardDeviation(list, out num);
List<CustomTaxonData> taxonDatas = new List<CustomTaxonData>();
foreach (KeyValuePair<ITaxon, uint> keyValuePair in taxaCount)
{
int size = this.GetSize((double)((float)keyValuePair.Value), num, num1);
string str = (keyValuePair.Key is HierarchicalTaxon ? (keyValuePair.Key as HierarchicalTaxon).FullUrl : keyValuePair.Key.UrlName.Value);
Guid? dummyNull = null;
CustomTaxonData taxonDatum = new CustomTaxonData()
{
TaxonId = keyValuePair.Key.Id,
ParentTaxonId = (keyValuePair.Key as HierarchicalTaxon).Parent != null ? (keyValuePair.Key as HierarchicalTaxon).Parent.Id : dummyNull,
Title = keyValuePair.Key.Title,
Count = keyValuePair.Value,
Size = size,
Url = this.BuildUrl(str)
};
taxonDatas.Add(taxonDatum);
}
if (!this.ShowItemCount)
{
taxonDatas.Sort((CustomTaxonData a, CustomTaxonData b) => a.Title.CompareTo(b.Title));
}
return taxonDatas;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment