Esempio n. 1
0
        public static bool TryParse(ReadOnlySpan <char> text, [MaybeNullWhen(returnValue: false)] out Rtttl rtttl)
        {
            rtttl = null;

            var endOfName = text.IndexOf(Separator);

            var readOnlySpan = text.Slice(0, endOfName);

#if NETSTANDARD2_1
            var name = new string(readOnlySpan);
#else
            var name = new string(readOnlySpan.ToArray());
#endif

            text = text.Slice(endOfName + 1);

            var endOfSettings = text.IndexOf(Separator);

            if (!RtttlSettings.TryParse(text.Slice(0, endOfSettings), out var rtttlSettings))
            {
                return(false);
            }

            if (!TryParseNotes(text.Slice(endOfSettings + 1), out var notes))
            {
                return(false);
            }

            rtttl = new Rtttl(name, rtttlSettings, notes);

            return(true);
        }
Esempio n. 2
0
 public Rtttl(string name, RtttlSettings settings, IReadOnlyCollection <Note> notes)
 {
     Name     = name;
     Settings = settings;
     Notes    = notes;
 }