public DenseFeaturesFromEntity(IEnumerable rgFeature, FeatureSerializer featureSerializer) { FeatureSerializer = featureSerializer; _rgFeatureDictionary = new Hashtable(); foreach (Feature aFeature in rgFeature) { string sXml = FeatureSerializer.ToXml(aFeature); _rgFeatureDictionary.Add(sXml, aFeature); } }
public override IDictionary FeatureDictionary(object entity) { Hashtable rgForEntity = new Hashtable(); foreach (Converter <object, IEnumerable> aFeaturesFromEntityFunction in _rgFeaturesFromEntityFunction) { IEnumerable rgEntitySomeFeatures = aFeaturesFromEntityFunction(entity); foreach (Feature aFeature in rgEntitySomeFeatures) { //!!!if nested features, implemented a good HashCode and Equal, then wouldn't need to hash on Xml, instead could has on the feature itself - but this would make defining features more work. string sXml = _featureSerializer.ToXml(aFeature); if (_rgFeatureDictionary.Contains(sXml)) { rgForEntity.Add(sXml, aFeature); } } } return(rgForEntity); }