Пример #1
0
        public ITuning Add(string name, FullNote[] rootNotes)
        {
            if (ReadOnly)
            {
                throw new ObjectIsReadOnlyException(this);
            }

            Tuning tuning = new Tuning(this, name, rootNotes);

            Add(tuning);
            return(tuning);
        }
Пример #2
0
        public int CompareTo(object obj)
        {
            if (null == obj)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            Tuning tuning = obj as Tuning;

            if (null == tuning)
            {
                throw new ArgumentException();
            }

            return(LongName.CompareTo(tuning.LongName));
        }
Пример #3
0
        public void Read(XmlReader xmlReader)
        {
            if (null == xmlReader)
            {
                throw new ArgumentNullException(nameof(xmlReader));
            }

            using (xmlReader)
            {
                do
                {
                    if (xmlReader.IsStartElement() && xmlReader.Name == "tuning")
                    {
                        Tuning tuning = new Tuning(this, xmlReader.ReadSubtree());
                        Add(tuning);
                    }
                } while (xmlReader.Read());
            }
        }
Пример #4
0
        internal void Resort(Tuning tuning, Action rollback)
        {
            if (Remove(tuning))
            {
                try
                {
                    Add(tuning);
                }
                catch (Exception ex)
                {
                    if (null != rollback)
                    {
                        rollback();

                        // Re-add since remove succeeded but re-add failed
                        if (null != (ex as TuningAlreadyExistsException))
                        {
                            Add(tuning);
                        }
                    }
                    throw;
                }
            }
        }