Ejemplo n.º 1
0
 public SentinelLoopSequenceResolverArgs(T seed, T terminal, U step, IntervalMode intervalMode)
 {
     Seed         = seed;
     Terminal     = terminal;
     Step         = step;
     IntervalMode = intervalMode;
 }
Ejemplo n.º 2
0
        public Interval(int pitch, bool isInTonality)
        {
            Interval i = Interval.fromPitch(pitch, isInTonality);

            this.distance  = i.distance;
            this.mode      = i.mode;
            this.direction = i.direction;
        }
Ejemplo n.º 3
0
        public Interval(int pitch)
        {
            Interval i = Interval.fromPitch(pitch, true);

            this.distance  = i.distance;
            this.mode      = i.mode;
            this.direction = i.direction;
        }
 /// <summary>
 /// Determines whether the specified value is within the interval.
 /// </summary>
 /// <typeparam name="TQuantity">The type of the quantity.</typeparam>
 /// <param name="quantity">The quantity.</param>
 /// <param name="interval">The interval.</param>
 /// <param name="intervalMode">The interval mode.</param>
 /// <returns>
 ///   <c>true</c> if the specified quantity is within the interval, otherwise <c>false</c>.
 /// </returns>
 public static bool IsWithin <TQuantity>(
     this TQuantity quantity,
     Interval <TQuantity> interval,
     IntervalMode intervalMode = IntervalMode.Inclusive)
     where TQuantity : IQuantity
 {
     return(interval.Contains(quantity, intervalMode));
 }
Ejemplo n.º 5
0
 public MonthlyTrigger(int interval, IntervalMode mode, StartModel startModel, TimeZoneInfo timeZone) : base(timeZone)
 {
     _interval = interval;
     _         = startModel ?? throw new ArgumentNullException();
     _mode     = mode;
     _nth      = startModel.Nth;
     if (mode == IntervalMode.DayOfWeek)
     {
         _dayOfWeek = startModel.DayOfWeek;
     }
 }
        /// <summary>
        /// Determines whether the specified value is within the interval.
        /// </summary>
        /// <typeparam name="TQuantity">The type of the quantity.</typeparam>
        /// <typeparam name="TUnitSelector">The type of the unit selector.</typeparam>
        /// <param name="quantity">The quantity.</param>
        /// <param name="min">The minimum.</param>
        /// <param name="max">The maximum.</param>
        /// <param name="unitSelector">The unit selector.</param>
        /// <param name="intervalMode">The interval mode.</param>
        /// <returns>
        ///   <c>true</c> if the specified quantity is within the interval, otherwise <c>false</c>.
        /// </returns>
        public static bool IsWithin <TQuantity, TUnitSelector>(
            this IQuantity <TQuantity, TUnitSelector> quantity,
            double min,
            double max,
            SelectUnit <TUnitSelector> unitSelector,
            IntervalMode intervalMode = IntervalMode.Inclusive)
            where TQuantity : IQuantity
        {
            var unit = UnitBuilder.BuildUnit(unitSelector(quantity.CreateUnitSelector()));

            return(quantity.ToDouble(unit).IsWithinInterval(min, max, intervalMode));
        }
Ejemplo n.º 7
0
 public Interval(IntervalMode mode, double time, string value)
 {
     Mode  = mode;
     Time  = time;
     Value = value;
 }
Ejemplo n.º 8
0
 public Interval(IntervalMode mode, double time, string value)
 {
     Mode = mode;
     Time = time;
     Value = value;
 }
Ejemplo n.º 9
0
 public SentinelLoopXml()
 {
     IntervalMode = IntervalMode.Close;
 }
Ejemplo n.º 10
0
        public static RangeDictionary <TKey, TValue> ToRangeDictionary <TSource, TKey, TValue>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TValue> valueSelector, IntervalMode intervalMode) where TKey : IComparable <TKey>
        {
            var result = new RangeDictionary <TKey, TValue>(intervalMode);

            foreach (var v in source)
            {
                var key = keySelector(v);
                if (!result.ContainsKey(key))
                {
                    result.Add(keySelector(v), valueSelector(v));
                }
                else
                {
                    result[key] = valueSelector(v);
                }
            }
            return(result);
        }
Ejemplo n.º 11
0
 public static RangeDictionary <TKey, TSource> ToRangeDictionary <TSource, TKey>(this IEnumerable <TSource> source, Func <TSource, TKey> keySelector, IntervalMode intervalMode) where TKey : IComparable <TKey>
 {
     return(source.ToRangeDictionary(keySelector, (v) => v, intervalMode));
 }
Ejemplo n.º 12
0
 public Interval(int distance, IntervalMode mode, IntervalDirection direction)
 {
     this.distance  = distance;
     this.mode      = mode;
     this.direction = direction;
 }
Ejemplo n.º 13
0
        private ISequenceResolverArgs BuildSentinelLoopResolverArgs <T, U>(string seed, string terminal, string step, IntervalMode intervalMode)
        {
            var helper = new ScalarHelper(serviceLocator, globalVariables);

            var args = new SentinelLoopSequenceResolverArgs <T, U>(
                helper.InstantiateResolver <T>(seed).Execute(),
                helper.InstantiateResolver <T>(terminal).Execute(),
                helper.InstantiateResolver <U>(step).Execute(),
                intervalMode
                );

            return(args);
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Returns <c>true</c> if this instance is between the two instances given the <see cref="IntervalMode"/>.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="self"></param>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <param name="mode"></param>
 /// <returns></returns>
 public static bool Between <T>(this T self, T left, T right, IntervalMode mode = IntervalMode.Open)
     where T : IComparable <T>
 {
     return(Between(self, left, right, mode == IntervalMode.Open || mode == IntervalMode.HalfOpenLeft, mode == IntervalMode.Open || mode == IntervalMode.HalfOpenRight));
 }
Ejemplo n.º 15
0
 public Interval(IntervalMode mode, double time, string value)
 {
     _mode  = mode;
     _time  = time;
     _value = value;
 }
 /// <summary>
 /// Determines whether this interval contains the specified quantity.
 /// </summary>
 /// <param name="quantity">The quantity.</param>
 /// <param name="intervalMode">The interval mode.</param>
 /// <returns>
 ///   <c>true</c> if the specified quantity is within the interval, otherwise <c>false</c>.
 /// </returns>
 public bool Contains(TQuantity quantity, IntervalMode intervalMode = IntervalMode.Inclusive)
 {
     return(quantity.ToDouble(this.Unit).IsWithinInterval(this.Min, this.Max, intervalMode));
 }
Ejemplo n.º 17
0
 public RangeDictionary(IntervalMode mode, IDictionary <TKey, TValue> dic)
 {
     Mode       = mode;
     Dictionary = new SortedDictionary <TKey, TValue>(dic);
 }
Ejemplo n.º 18
0
        public void invert(bool invertDistance, bool invertMode, bool invertDirection)
        {
            if (invertDistance)
            {
                int octave  = 0;
                int newDist = this.distance;

                //Reduce to 1 octave
                while (newDist > Interval.INTERVAL_OCTAVE + 1)
                {
                    newDist -= Interval.INTERVAL_OCTAVE;
                    octave++;
                }

                //Inversion:
                // - newDist : 1-7
                // - if 1: inverted interval is 1
                // - if 2-7: inverted is 7-2 (9-newDist)
                if (newDist > 1)
                {
                    newDist = 9 - newDist;
                }

                // Recover octave
                newDist += Interval.INTERVAL_OCTAVE * octave;

                this.distance = newDist;
            }

            if (invertMode)
            {
                switch (this.mode)
                {
                case IntervalMode.DIMINISHED:
                    this.mode = IntervalMode.AUGMENTED;
                    break;

                case IntervalMode.AUGMENTED:
                    this.mode = IntervalMode.DIMINISHED;
                    break;

                case IntervalMode.MAJOR:
                    this.mode = IntervalMode.MINOR;
                    break;

                case IntervalMode.MINOR:
                    this.mode = IntervalMode.MAJOR;
                    break;

                case IntervalMode.PERFECT:     //do nothing
                    break;
                }
            }

            if (invertDirection)
            {
                if (this.direction == IntervalDirection.DECREASING)
                {
                    this.direction = IntervalDirection.INCREASING;
                }
                else
                {
                    this.direction = IntervalDirection.DECREASING;
                }
            }
        }