Esempio n. 1
0
        static Either <Exception, VibrateCommand> ParseVibrateLine(string s)
        {
            Arr <string> parts = new Arr <string>(s.ToLower().Split(' '));

            if (parts.Contains("start"))
            {
                Map <string, string> dict = new Map <string, string>(parts.Filter(s_ => s_.Contains("=")).Map(p =>
                {
                    string[] pp = p.Split('=');
                    return(pp.First(), pp.Last());
                }));
                try
                {
                    return(Right <VibrateCommand>(new VibrateStart(
                                                      dict["type"], dict.Find("time").Map(Double.Parse), dict.Find("interval").Map(Double.Parse), Double.Parse(dict["strength"]))));
                }
                catch (Exception e)
                {
                    return(Left(e));
                }
            }
            else if (parts.Contains("stop"))
            {
                return(Right <VibrateCommand>(new VibrateStop()));
            }
            else
            {
                return(Right <VibrateCommand>(new VibrateNone()));
            }
        }
Esempio n. 2
0
        internal ObservationsColumnViewModel(string columnName, Arr <string> subjects, Arr <double> observations)
        {
            RequireTrue(columnName.IsAString());
            RequireFalse(subjects.IsEmpty);
            RequireFalse(observations.IsEmpty);

            ColumnName = columnName;

            Subjects = subjects;

            _subject = subjects.Count == 1
        ? subjects.Head()
        : subjects.Contains(columnName)
          ? columnName
          : NO_SELECTION;

            Observations = observations;

            Content = Join("  ", observations);
        }
Esempio n. 3
0
 public bool Contains(T item) => Arr.Contains(item);