mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-12 19:25:00 +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
|
||||||
- Added Get and Set extensions to PropertyInfo in SIMPLSHARP to mimic overloads avaliable in NETSTANDARD
|
- 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 Collection extensions for setting and adding ranges of items
|
||||||
|
- Added a method for getting the total number of seconds in a date
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Repeater changed to use configured callbacks instead of a dumb event
|
- Repeater changed to use configured callbacks instead of a dumb event
|
||||||
|
|||||||
@@ -224,6 +224,15 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
minutes = MathUtils.Modulus(minutes + extends.Minute, 60);
|
minutes = MathUtils.Modulus(minutes + extends.Minute, 60);
|
||||||
return new DateTime(extends.Year, extends.Month, extends.Day, extends.Hour, minutes, extends.Second, extends.Millisecond);
|
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>
|
/// <param name="extends"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T Random<T>([NotNull] this IEnumerable<T> extends)
|
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)
|
if (extends == null)
|
||||||
throw new ArgumentNullException("extends");
|
throw new ArgumentNullException("extends");
|
||||||
@@ -1099,7 +1115,6 @@ namespace ICD.Common.Utils.Extensions
|
|||||||
if (sequence.Count == 0)
|
if (sequence.Count == 0)
|
||||||
throw new InvalidOperationException("Sequence is empty.");
|
throw new InvalidOperationException("Sequence is empty.");
|
||||||
|
|
||||||
Random random = new Random(Guid.NewGuid().GetHashCode());
|
|
||||||
int index = random.Next(0, sequence.Count);
|
int index = random.Next(0, sequence.Count);
|
||||||
|
|
||||||
return sequence[index];
|
return sequence[index];
|
||||||
|
|||||||
Reference in New Issue
Block a user