Beispiel #1
0
        /// <summary>
        /// Adds clef information to an empty Clef object
        /// </summary>
        /// <param name="_clefobj">Empty clef object</param>
        /// <param name="_meiclef">MEI clef element</param>
        /// <returns>Clef with data</returns>
        public static Model.Clef ConvertClef(Model.Clef _clefobj, mei.Clef _meiclef)
        {
            _clefobj.Line  = ReadLine(_meiclef);
            _clefobj.Shape = ConvertClefshape(_meiclef);

            return(_clefobj);
        }
        public void Cleanup()
        {
            clefobj = null;
            meiclef = null;

            barline    = null;
            meibarline = null;

            unclear = null;

            meicustos = null;
            custos    = null;
        }
        public void Init()
        {
            clefobj = new Model.Clef();
            meiclef = new mei.Clef();

            barline    = new Model.Barline();
            meibarline = new mei.BarLine();

            unclear = new mei.Unclear();

            meicustos = new mei.Custos();
            custos    = new Model.Custos();
        }
Beispiel #4
0
 /// <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!");
     }
 }
Beispiel #5
0
 /// <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);
     }
 }