mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Adding Extensions methods in order to handle the switching of the animations.
This commit is contained in:
committed by
Chris Cameron
parent
75404e8b20
commit
00a75c6d72
@@ -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
|
||||
|
||||
@@ -225,5 +225,14 @@ namespace ICD.Common.Utils.Extensions
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user