private void ClusterOneModel(IClusteringStrategy strategy, NullableDictionary<object, ICluster> map, object model)
{
object clusterKey = strategy.GetClusterKey(model);
// If the returned value is an IEnumerable, that means the given model can belong to more than one cluster
IEnumerable keyEnumerable = clusterKey as IEnumerable;
if (clusterKey is string || keyEnumerable == null)
keyEnumerable = new object[] {clusterKey};
// Deal with nulls and DBNulls
ArrayList nullCorrected = new ArrayList();
foreach (object key in keyEnumerable) {
if (key == null || key == System.DBNull.Value) {
if (this.TreatNullAsDataValue)
nullCorrected.Add(null);
} else nullCorrected.Add(key);
}
// Group by key
foreach (object key in nullCorrected) {
if (map.ContainsKey(key))
map[key].Count += 1;
else
map[key] = strategy.CreateCluster(key);
}
}