Beispiel #1
0
        /// <summary>
        /// Converts length from the specified length type to <see cref="long"/>.
        /// </summary>
        /// <param name="length">Length to convert.</param>
        /// <param name="time">Start time of an object to convert length of.</param>
        /// <param name="tempoMap">Tempo map used to convert <paramref name="length"/>.</param>
        /// <returns>Length as <see cref="long"/>.</returns>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="time"/> is negative.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="length"/> is null. -or-
        /// <paramref name="tempoMap"/> is null.</exception>
        public static long ConvertFrom(ILength length, long time, TempoMap tempoMap)
        {
            ThrowIfArgument.IsNull(nameof(length), length);
            ThrowIfTimeArgument.IsNegative(nameof(time), time);
            ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap);

            return(LengthConverterFactory.GetConverter(length.GetType())
                   .ConvertFrom(length, time, tempoMap));
        }
Beispiel #2
0
 /// <summary>
 /// Gets converter that can be used to convert length of an object from <see cref="long"/>
 /// to the specified length type and vice versa.
 /// </summary>
 /// <typeparam name="TLength">Type that will represent the length of an object.</typeparam>
 /// <returns>Converter to convert length between <see cref="long"/> and <typeparamref name="TLength"/>.</returns>
 /// <exception cref="NotSupportedException"><typeparamref name="TLength"/> is not supported.</exception>
 public static ILengthConverter GetConverter <TLength>()
     where TLength : ILength
 {
     return(LengthConverterFactory.GetConverter <TLength>());
 }