Found 18 packages
Disables DateTime.Now, in favor of DateTime.UtcNow
A simple abstraction over C#'s DateTime.Now, DateTime.Today and DateTime.UtcNow so you can control these values in your tests.
UtcMilliTime for .NET 8.0 + .NET 10+ provides Unix time milliseconds (Int64) timestamps, similar to JavaScript's Date.now(), with cross-platform support and NTP synchronization. Features Task-based async APIs, async Main support, conversion extensions (ToIso8601String, ToUtcDateTime, etc.), and new chaining methods for timestamp manipulations (e.g., AddHours, SubtractDays). Usage: using UtcMilliTime; ITime time = Clock.Time; time.SuppressNetworkCalls = false; // Enable NTP sync var timestamp = time.Now; // Int64 timestamp string iso = timestamp.ToIso8601String(); // ISO-8601 string For async Main: await Clock.CreateAsync(); See https://github.com/JPKusumi/UtcMilliTime for details.
Mockable wrapper around DateTime.Now and DateTime.UtcNow.
Provides a testable abstraction and alternative to DateTime.Now / DateTime.UtcNow
Detects DateTime.Now and DateTime.UtcNow.Converts them into Object Creation
Creates a Version from DateTime.UtcNow
Provides the basis for implementing the Ambient Context pattern. Includes a Clock implementation based on it. The Ambient Context pattern is an Inversion of Control (IoC) pattern that provides static access to a dependency while controlling the dependency from the outside. The pattern optimizes code reachability at the cost of reduced transparency, making it suitable for obvious, ubiquitous, rarely-changing dependencies. For example, an entity's constructor can access Clock.UtcNow, avoiding the need to inject the creation datetime or a dependency, at the cost of hiding the fact that a unit test could control the timestamp from the outside. An example from .NET is System.Transactions.TransactionScope. Any code (such as the database connector) can access the static Transaction.Current, yet outer code in the current execution flow controls it, through TransactionScopes. https://github.com/TheArchitectDev/Architect.AmbientContexts Release notes: 2.0.1: - Updated dependencies to the latest versions and removed some unused dependencies. 2.0.0: - BREAKING: ClockScope no longer has a configurable default scope. (See also next item). - BREAKING: Removed explicit support for "configured default scopes", i.e. scopes configured on startup. They posed too many concurrency risks, such as in test runs. (Default scopes without any configuration are still supported.) - BREAKING: Removed the RemoveAmbientScope() method. Deactivate() should be used instead. - Added support for netstandard2.0. - ClockScope's constructor now prefers UTC datetimes, to avoid lossy conversions (due to DST). - ClockScope now exposes a convenience constructor that takes a DateTime instead of a Func<DateTime>. 1.1.1: - Manually disposing scopes from a deeper async level (such as a DisposeAsync() method with the async keyword) now properly affects methods up the call stack and no longer breaks scope nesting. - Improved the protections against race conditions. - Parent properties are no longer unset on disposal (although implementations should not rely on this detail). - Performance improvement: A scope now avoids even instantiating its AsyncLocal as long as only its default scope is used, as is common in production for certain scopes. - Performance improvement: The JIT can now inline more code, since exceptions have been moved into helper methods. 1.1.0: - Introduced non-generic AmbientScope base class. - Performance improvement: A scope now avoids touching its AsyncLocal as long as only its default scope is used, as is common in production for certain scopes.
Module which is used for getting the current time. This should be used instead of DateTime.(Utc)Now in order for the time to always be of the same kind and the code to be more easily testable.
DateTimeProviders aims to solve the problems around testing code that has dependencies on the DateTime/DateTimeOffset structs, and also enforcing consistent use of Now and UtcNow.
A simple library for abstracting static properties such as 'Now', 'UtcNow' and 'Today' in .NET's 'System.DateTime' and 'System.DateTimeOffset' structs so that methods using these can be unit tested
Reliable unique ID generation and management for distributed applications. Auto-increment IDs reveal sensitive information. UUIDs (also known as GUIDs) are inefficient as primary keys in a database. Having two different IDs is cumbersome and counterintuitive. We can do better. - For a 93-bit UUID replacement that is efficient as a primary key, use the DistributedId. - For a 128-bit 128-bit UUID replacement with the advantages of the DistributedId and practically no rate limits or collisions, at the cost of more space, use the DistributedId128. - To expose IDs externally in a sensitive environment where zero metadata must be leaked, transform them with PublicIdentities. https://github.com/TheArchitectDev/Architect.Identities Release notes: 2.1.1: - Enhancement: Upgraded package versions. 2.1.0: - Semi-breaking: IPublicIdentityConverter now features additional methods, although the type is generally not user-implemented. - Semi-breaking: HexadecimalIdEncoder's char-based parameters have been renamed from "bytes" to "chars". - Added DistributedId128, a 128-bit (Guid/UInt128) DistributedId variant with practically no rate limits or collisions that also doubles as a version-7 UUID. - Added encoding methods for UInt128. - Added extension methods to transcode between UInt128 and Guid. - Added public identity conversions for UInt128 and Guid. - DistributedIdGeneratorScope and DistributedId128GeneratorScope now expose the CurrentGenerator property, which helps when implementing generators that need to piggyback on the encapsulated generator. 2.0.0: - BREAKING: Removed Fluid. Ambient scopes with startup configuration are now considered undesirable. - BREAKING: Removed ApplicationInstanceId. Ambient scopes with startup configuration are now considered undesirable. - BREAKING: Removed ambient access to IPublicIdentityConverter. Ambient scopes with startup configuration are now considered undesirable. - BREAKING: IdEncoder has been reworked into BinaryIdEncoder, AphanumericIdEncoder, and HexadecimalIdEncoder. - BREAKING: ID decoding methods now throw if the input is too long. This is specially relevant for strings (such as query parameters) where 0123456789123456 and 0123456789123456aaaa should not produce the same ID. - BREAKING: IPublicIdentityConverter now throws on big-endian architectures, instead of risking silent portability issues between architectures. - BREAKING: Now using AmbientContexts 2.0.0. - Semi-breaking: DistributedIds are now always 28 digits, to avoid a change from 27 to 28 digits in the future. Newly generated IDs will be significantly greater than before. Avoid downgrading after upgrading. - DistributedIds can now burst-generate ~128,000 IDs at once before the ~128 IDs per millisecond throttling kicks in. This makes throttling much less likely to be encountered. - DistributedId now stays incremental even under clock adjustments of up to 1 second. (Note that the UTC clock remains unaffected by DST.) - Hexadecimal ID encodings are now supported. - IPublicIdentityConverter now comes with a TestPublicIdentityConverter implementation for unit tests. - Added UnsupportedOSPlatform("browser") to PublicIdentities, due to continuing lack of AES support. 1.0.2: - Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance. 1.0.1: - Now using AmbientContexts 1.1.0, for a performance improvement.
Provides an interface containing Now() and UtcNow(), and two implementation classes. One is a wrapper for DateTime. The other is for use in unit tests, and returns a DateTime value supplied by the test.
This client library is a powerful tool for MSSQL/PostgreSQL. This tool allows to easy execute command/procedure with using only one line of code. Samples - https://github.com/tomaszmargacz/nuget-samples/tree/master/DotNet.Database.Sample If you have any questions or need improvement feel free to contact me: tomasz.margacz@gmail.com Sample code: var selectCommandWithParam = _dbClient.ExecuteCommand<TestModel>("Select * from dbo.Test where id = @id", new { id = selectCommand.FirstOrDefault().Id }); var selectProcedureWithParam = _dbClient.ExecuteStoredProcedure<TestModel>("dbo.GetTest", new { id = selectProcedure.FirstOrDefault().Id }); int insertCount = _dbClient.ExecuteCommand<int>("INSERT INTO dbo.Test (id, text, rate, created) VALUES (@id, @text, @rate, @created)", new { id = Guid.NewGuid().ToString(), text = "Test", rate = 1.2, created = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") });
The DateTime construct has the disadvantage that testing can become very difficult. Especially in cases where DateTime.Now, DateTime.Utc or for example DateTime.Today is used. These methods lead to UnitTest not being possible or breaking after a certain date. By using an adapter, a facade can be injected at runtime via Dependency Injection (DI). For testing, a mock can be used to make the functionality testable.
This client library is a powerful tool for Azure Redis Cache services. This tool allows to easy set/get to cache service with using only one line of code. If you have any questions or need improvement feel free to contact me: tomasz.margacz@gmail.com Sample code: // init RedisCacheQuick redis = new RedisCacheQuick("***.redis.cache.windows.net:***,password=***,ssl=***,abortConnect=***"); // set string redis.StringSet("keyName_1", "Sample text."); // get string string value_1 = redis.StringGet("keyName_1"); // set any object - DateTime, int, double, ... redis.Set("keyName_2", DateTime.UtcNow); // get any object DateTime value_2 = redis.Get<DateTime>("keyName_2"); // get object DateTime? value_not_exists = redis.Get<DateTime?>("keyName_not_exists"); // return value will be null // set own object redis.Set("keyName_3", new Employee(1, "Name1")); // get own object Employee value_3 = redis.Get<Employee>("keyName_3"); --- public class Employee { public int Id { get; set; } public string Name { get; set; } public Employee(int id, string name) { this.Id = id; this.Name = name; } }
SmartApp.lk.Mongo.Logger Log is a lightweight logging library for .NET applications, enabling seamless logging of application events, errors, and performance metrics directly to a MongoDB database. This package helps you centralize your logs, making them easily accessible for monitoring, analysis, and troubleshooting. Key Features: - Easy integration with .NET applications - Support for various log levels (Info, Debug, Error, etc.) - Automatic handling of log rotations and archival - Flexible configuration options - Asynchronous logging for minimal performance impact - Structured logging with custom fields - Compatibility with .NET Core 8 and .NET Framework Installation: 1. Install the package via NuGet: `dotnet add package SmartApp.lk.Mongo.Logger` 2. Configure your MongoDB connection string and logging settings in the application configuration file. Usage: Program.cs var configuration = builder.Configuration builder.Services.SmartApplkMongoLogerServices<SMARTAppLOGER>( new Option { IsDeleteCollection = true, KeepLastCollection = 5, CollectionCreateWithin = CollectionCreateWithin.BYHOURS, connectionString = configuration.GetConnectionString("MongoConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."), databaseName = configuration.GetConnectionString("MongoDatabase") ?? throw new InvalidOperationException("Databasse string 'DefaultConnection' not found."), }); await this.smartMongoLoger.InsertAsync(new SmartLogger<SMARTAppLOGER> { LogModel = new SMARTAppLOGER { CreatedDate = DateTime.Now, ErrorMasg = "error Description" } },DateTime.UtcNow);
SmartApp.lk.Mongo.Logger Log is a lightweight logging library for .NET applications, enabling seamless logging of application events, errors, and performance metrics directly to a MongoDB database. This package helps you centralize your logs, making them easily accessible for monitoring, analysis, and troubleshooting. Key Features: - Easy integration with .NET applications - Support for various log levels (Info, Debug, Error, etc.) - Automatic handling of log rotations and archival - Flexible configuration options - Asynchronous logging for minimal performance impact - Structured logging with custom fields - Compatibility with .NET Core 8 and .NET Framework Installation: 1. Install the package via NuGet: `dotnet add package SmartApp.lk.Mongo.Logger` 2. Configure your MongoDB connection string and logging settings in the application configuration file. Usage: Program.cs var configuration = builder.Configuration builder.Services.SmartApplkMongoLogerServices<SMARTAppLOGER>( new Option { IsDeleteCollection = true, KeepLastCollection = 5, CollectionCreateWithin = CollectionCreateWithin.BYHOURS, connectionString = configuration.GetConnectionString("MongoConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."), databaseName = configuration.GetConnectionString("MongoDatabase") ?? throw new InvalidOperationException("Databasse string 'DefaultConnection' not found."), }); await this.smartMongoLoger.InsertAsync(new SmartLogger<SMARTAppLOGER> { LogModel = new SMARTAppLOGER { CreatedDate = DateTime.Now, ErrorMasg = "error Description" } },DateTime.UtcNow);