예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public Instrument(InstrumentSpec spec)
 {
     Spec = spec;
 }
예제 #4
0
 public Instrument(String serialNumber, double price, InstrumentSpec spec)
 {
     SerialNumber = serialNumber;
     Price        = price;
     Spec         = spec;
 }