-
-
Notifications
You must be signed in to change notification settings - Fork 9
Simplify.System
Provides classes to get assembly information and ambient context for wrapping DateTime.Now
, DateTime.UtcNow
, DateTime.Today
properties.
Available at NuGet as binary package and source package
Provides IAssemblyInfo
interface and AssemblyInfo
class to get assembly information.
With AssemblyInfo
you can get assembly version, product name, description, copyright, company name information.
AssemblyInfo.Entry
static ambient context provides information about Entry assembly.
AssemblyInfo
can be instantiated to get specified assembly information:
var assemblyInfo = new AssemblyInfo(Assembly.GetAssembly(typeof(SomeClass)));
Provides ITimeProvider
interface and TimeProvider
class for mocking and using DateTime.Now
, DateTime.UtcNow
, DateTime.Today
properties.
With TimeProvider.Current
ambient context you can easily get actual DateTime.Now
, DateTime.UtcNow
, DateTime.Today
properties or mock them when you want.
By default TimeProvider.Current
initialized with SystemTimeProvider class which wraps system DateTime.Now
, DateTime.UtcNow
, DateTime.Today
properties.
// Will return actual DateTime.Now
var currentTime = TimeProvider.Current.Now;
var fakeTimeProvider = new Mock<ITimeProvider>();
fakeTimeProvider.SetupGet(x => x.Now).Returns(new DateTime(2014, 10, 10));
TimeProvider.Current = fakeTimeProvider.Object;
// Will return fake value
var time = TimeProvider.Current.Now;
// Converts bytes array to astring.
public static string GetString(this byte[] bytes);
// Checking what two double values most likely the same ( the difference between values is less than Epsilon)
public static bool AreSameAs(this double a, double b);
// Convert string to the bytes array.
public static byte[] ToBytesArray(this string str);
// Converts the specified string representation of a date and time to its DateTime? equivalent using the specified format, invariant culture format information. The format of the string representation must match at least one of the specified formats exactly. The method returns a value if the conversion succeeded otherwise null
public static DateTime? TryToDateTimeExact(this string s, string format);
// Removes milliseconds from the DateTime
public static DateTime TrimMilliseconds(this DateTime dt);