/// <summary> /// Converts time from the specified time type to <see cref="long"/>. /// </summary> /// <param name="time">Time to convert.</param> /// <param name="tempoMap">Tempo map used to convert <paramref name="time"/>.</param> /// <returns>Time as <see cref="long"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="time"/> is null. -or- /// <paramref name="tempoMap"/> is null.</exception> public static long ConvertFrom(ITime time, TempoMap tempoMap) { ThrowIfArgument.IsNull(nameof(time), time); ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap); return(TimeConverterFactory.GetConverter(time.GetType()) .ConvertFrom(time, tempoMap)); }
/// <summary> /// Gets converter that can be used to convert time of an object from <see cref="long"/> /// to the specified time type and vice versa. /// </summary> /// <typeparam name="TTime">Type that will represent the time of an object.</typeparam> /// <returns>Converter to convert time between <see cref="long"/> and <typeparamref name="TTime"/>.</returns> /// <exception cref="NotSupportedException"><typeparamref name="TTime"/> is not supported.</exception> public static ITimeConverter GetConverter <TTime>() where TTime : ITime { return(TimeConverterFactory.GetConverter <TTime>()); }