public virtual bool Matches(InstrumentSpec matchSpec) { // matchSpec has some property that this does not if (matchSpec.SpecPropKeys.Intersect(properties.Keys).Count() != matchSpec.SpecPropKeys.Count()) { return(false); } foreach (SpecProps theProperty in matchSpec.SpecPropKeys) { if (matchSpec[theProperty] is String) { String matchValue = matchSpec[theProperty] as String; if (!matchValue.Equals(properties[theProperty] as String, StringComparison.OrdinalIgnoreCase)) { return(false); } } else if (!matchSpec[theProperty].Equals(properties[theProperty])) { return(false); } } return(true); }
public IEnumerable <Instrument> Search(InstrumentSpec searchSpec) { //TODO why doesn't this work? //IEnumerable<Instrument> matches = inventory.Where(i => i.Spec.Matches(searchSpec)); List <Instrument> matches = new List <Instrument>(); foreach (Instrument instrument in inventory) { if (instrument.Spec.Matches(searchSpec)) { matches.Add(instrument); } } return(matches); }
public Instrument(InstrumentSpec spec) { Spec = spec; }
public Instrument(String serialNumber, double price, InstrumentSpec spec) { SerialNumber = serialNumber; Price = price; Spec = spec; }