feat: Adding Extensions methods in order to handle the switching of the animations.

This commit is contained in:
Laura Gomez
2020-07-31 09:56:03 -04:00
committed by Chris Cameron
parent 75404e8b20
commit 00a75c6d72
3 changed files with 27 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Added Get and Set extensions to PropertyInfo in SIMPLSHARP to mimic overloads avaliable in NETSTANDARD
- Added Collection extensions for setting and adding ranges of items
- Added a method for getting the total number of seconds in a date
### Changed
- Repeater changed to use configured callbacks instead of a dumb event

View File

@@ -224,6 +224,15 @@ namespace ICD.Common.Utils.Extensions
minutes = MathUtils.Modulus(minutes + extends.Minute, 60);
return new DateTime(extends.Year, extends.Month, extends.Day, extends.Hour, minutes, extends.Second, extends.Millisecond);
}
/// <summary>
/// Returns the total number of seconds since DateTime.MinValue
/// </summary>
/// <param name="extends"></param>
/// <returns></returns>
public static double GetTotalSeconds(this DateTime extends)
{
return (extends - DateTime.MinValue).TotalSeconds;
}
}
}

View File

@@ -1090,6 +1090,22 @@ namespace ICD.Common.Utils.Extensions
/// <param name="extends"></param>
/// <returns></returns>
public static T Random<T>([NotNull] this IEnumerable<T> extends)
{
if (extends == null)
throw new ArgumentNullException("extends");
Random random = new Random(Guid.NewGuid().GetHashCode());
return extends.Random(random);
}
/// <summary>
/// Returns a random item from the given sequence.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="extends"></param>
/// <param name="random"></param>
/// <returns></returns>
public static T Random<T>([NotNull] this IEnumerable<T> extends, [NotNull] Random random)
{
if (extends == null)
throw new ArgumentNullException("extends");
@@ -1099,7 +1115,6 @@ namespace ICD.Common.Utils.Extensions
if (sequence.Count == 0)
throw new InvalidOperationException("Sequence is empty.");
Random random = new Random(Guid.NewGuid().GetHashCode());
int index = random.Next(0, sequence.Count);
return sequence[index];