/// <summary> /// Parse celf/@shape into Model.Clefshape /// </summary> /// <param name="_meiclef">MEI clef element</param> /// <returns>Model.Clefshape</returns> private static Model.Clefshape ConvertClefshape(mei.Clef _meiclef) { if (_meiclef.GetShapeValue() == null) { return(Model.Clefshape.Null); } else if (Enum.TryParse(_meiclef.GetShapeValue(), true, out Model.Clefshape shape)) { return(shape); } else { throw new InvalidOperationException("Invalid value of clef/@shape!"); } }
/// <summary> /// Reads @line and converts to int /// </summary> /// <param name="_meiclef">MEI clef element</param> /// <returns>parsed @line value as int</returns> private static int ReadLine(mei.Clef _meiclef) { if (_meiclef.GetShapeValue() != null) { if (_meiclef.GetLineValue() == null) { throw new NullReferenceException("Clef has no line!"); } else if (Int32.TryParse(_meiclef.GetLineValue(), out int value)) { return(value); } else { throw new InvalidOperationException($"Parsing {_meiclef.GetLineAttribute().Name.LocalName} of clef failed!"); } } else { return(0); } }