public IInstrument GetInstrument() { string name = Settings[Prefix + "instrument"]; string level = InstrumentTuningLevel; if (null != _cachedInstrument) { if (_cachedInstrument.Name == name && _cachedInstrument.Level == level) { return(_cachedInstrument); } _cachedInstrument = null; _cachedTuning = null; } InstrumentSet instruments = _configFile.Instruments; while (null != instruments) { if (instruments.Level == level) { if (instruments.TryGet(name, out Instrument i)) { _cachedInstrument = i; break; } } instruments = instruments.Parent; } return(_cachedInstrument); }
public ConfigFile(string level) { Level = level; ChordiousSettings = new ChordiousSettings(level); DiagramStyle = new DiagramStyle(level); Instruments = new InstrumentSet(level); ChordQualities = new ChordQualitySet(level); Scales = new ScaleSet(level); DiagramLibrary = new DiagramLibrary(DiagramStyle); }
public void CopyFrom(InstrumentSet instrumentSet) { if (null == instrumentSet) { throw new ArgumentNullException(nameof(instrumentSet)); } foreach (Instrument sourceInstrument in instrumentSet) { if (!TryGet(sourceInstrument.Name, out Instrument instrument)) { instrument = Add(sourceInstrument.Name, sourceInstrument.NumStrings); } if (sourceInstrument.NumStrings == instrument.NumStrings) { instrument.Tunings.CopyFrom(sourceInstrument.Tunings); } } }
internal InstrumentSet(InstrumentSet parent, string level) : this(level) { Parent = parent ?? throw new ArgumentNullException(nameof(parent)); }
public InstrumentNameAlreadyExistsException(InstrumentSet instrumentSet, string name) : base(instrumentSet, name) { }
public InstrumentNotFoundException(InstrumentSet instrumentSet, string name) : base(instrumentSet, name) { }
public TargetInstrumentException(InstrumentSet instrumentSet, string name) : base(instrumentSet) { Name = name; }
public InstrumentSetException(InstrumentSet instrumentSet) : base() { InstrumentSet = instrumentSet; }
internal Instrument(InstrumentSet parent, XmlReader xmlReader) : this(parent) { Read(xmlReader); }
internal Instrument(InstrumentSet parent, string name, int numStrings) : this(parent) { Name = name; NumStrings = numStrings; }
private Instrument(InstrumentSet parent) { ReadOnly = false; _tunings = new TuningSet(this); Parent = parent; }