コード例 #1
0
        internal static ParsingResult TryParse(string input, out MidiTimeSpan timeSpan)
        {
            timeSpan = null;

            if (string.IsNullOrWhiteSpace(input))
            {
                return(ParsingResult.EmptyInputString);
            }

            var match = ParsingUtilities.Match(input, Patterns);

            if (match == null)
            {
                return(ParsingResult.NotMatched);
            }

            long midiTimeSpan;

            if (!ParsingUtilities.ParseNonnegativeLong(match, TimeSpanGroupName, 0, out midiTimeSpan))
            {
                return(ParsingResult.Error(OutOfRange));
            }

            timeSpan = new MidiTimeSpan(midiTimeSpan);
            return(ParsingResult.Parsed);
        }
コード例 #2
0
ファイル: MidiTimeSpan.cs プロジェクト: mbyht/drywetmidi
 /// <summary>
 /// Converts the string representation of a MIDI time span to its <see cref="MidiTimeSpan"/>
 /// equivalent. A return value indicates whether the conversion succeeded.
 /// </summary>
 /// <param name="input">A string containing a time span to convert.</param>
 /// <param name="timeSpan">When this method returns, contains the <see cref="MidiTimeSpan"/>
 /// equivalent of the time span contained in <paramref name="input"/>, if the conversion succeeded, or
 /// null if the conversion failed. The conversion fails if the <paramref name="input"/> is null or
 /// <see cref="String.Empty"/>, is not of the correct format. This parameter is passed uninitialized;
 /// any value originally supplied in result will be overwritten.</param>
 /// <returns>true if <paramref name="input"/> was converted successfully; otherwise, false.</returns>
 public static bool TryParse(string input, out MidiTimeSpan timeSpan)
 {
     return(MidiTimeSpanParser.TryParse(input, out timeSpan).Status == ParsingStatus.Parsed);
 }