WispFramework 1.1.12
dotnet add package WispFramework --version 1.1.12
NuGet\Install-Package WispFramework -Version 1.1.12
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WispFramework" Version="1.1.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WispFramework --version 1.1.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WispFramework, 1.1.12"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WispFramework as a Cake Addin #addin nuget:?package=WispFramework&version=1.1.12 // Install WispFramework as a Cake Tool #tool nuget:?package=WispFramework&version=1.1.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WispFramework
The Goal
The goal of this project is to facilitate development of a robust code-base by providing tools, utilities, and extensions.
Example Code
Subject Observable Pattern
// a subject whose state can be observed and throws an event when changed
Sub<bool> hasCoffee = new Sub<bool>(false);
// triggers the ValueChanged event
hasCoffee.Value = true;
ExpirableCache
var cache = new ExpirableCache<Guid, string>(TimeSpan.FromSeconds(1f));
// when expiration occurs, the item is removed from the cache
cache[k1] = "I will expire in 1 second";
Dynamic Object
// initialize a dynamic that generates a random string when Value is requested
var dyn = new Dynamic<string>(() => RandomUtil.RandomString(1, 5));
// will print a random string every time
for (int i = 0; i < 10; i++)
{
Console.WriteLine(dyn.Value);
}
// when throttled we use the cached data until expiry time
dyn = new Dynamic<string>(() => RandomUtil.RandomString(1, 5))
.Throttle(TimeSpan.FromSeconds(1));
// will print the same value unless 1 second has elapsed, in which case a new value will be generated
for (int i = 0; i < 10; i++)
{
Console.WriteLine(dyn.Value);
}
Sub and EventAwaiter
public static async void Run()
{
// we do not have coffee
Sub<bool> hasCoffee = new Sub<bool>(false);
Task.Run(() => NewMethod(hasCoffee));
string input;
// if input is 'give coffee' set hasCoffee value to true
while ((input = Console.ReadLine()) != "exit")
{
if (input == "give coffee")
{
hasCoffee.Value = true;
}
}
}
private static async Task NewMethod(Sub<bool> hasCoffee)
{
// here we await for the ValueChanged event to occur
var waitForCoffee = new EventAwaiter<ValueChangedEventArgs<bool>>(
h => hasCoffee.ValueChanged += h,
h => hasCoffee.ValueChanged -= h);
await waitForCoffee.Task;
try
{
Console.WriteLine($"Value changed for hasCoffee to {hasCoffee}");
}
catch (TimeoutException)
{
Console.WriteLine("We did not get coffee in time!");
}
}
Containers
Container ct = new Container();
ct.Register(new Car());
Console.WriteLine("Car found: " + ct.Resolve<Car>().Name);
ct.Register(new Boat());
Console.WriteLine("Boat found: " + ct.Resolve<Boat>().Name);
var specialBoat = new Boat() { Name = "Boat2" };
ct.Register(specialBoat, "Boat2");
var result = ct.Resolve<Boat>("Boat2");
result.cont.Register(result);
Console.WriteLine($"Special boat: {result.Name}");
Console.WriteLine($"Special boat: {result.cont.Resolve<Boat>().Name}");
var vehicles = ct.ResolveMany<IVehicle>().Select(t => t.Name);
var vehicleListStr = String.Join((string) ",", (IEnumerable<string>) vehicles);
Console.WriteLine($"Resolved IVehicles {vehicleListStr}");
Console.ReadLine();
Lazy Factory
var lazyFactory = new LazyFactory<int, Dynamic<string>>()
.SetInitializer(i =>
{
return new Dynamic<string>()
.SetEvaluator(() => $"Dyn {i}: " + " " +
RandomUtil.RandomString(RandomUtil.Range(1,
10)))
.Throttle(TimeSpan.FromSeconds(5));
});
Task.Run(async () =>
{
while (true)
{
for (var i = 0; i < 3; i++)
{
await Task.Delay(100);
Console.WriteLine(lazyFactory[i].Value);
}
}
});
Task Extensions
var time = DateTime.Now;
await Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(5));
})
.TimeoutAfter(TimeSpan.FromSeconds(1));
Assert.IsTrue(DateTime.Now - time < TimeSpan.FromSeconds(2));
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.12 | 1,345 | 6/30/2020 |
1.1.11 | 475 | 5/13/2020 |
1.1.10 | 438 | 5/13/2020 |
1.1.9 | 8,826 | 3/12/2020 |
1.1.8 | 646 | 1/29/2020 |
1.1.7 | 499 | 1/28/2020 |
1.1.6 | 508 | 1/28/2020 |
1.1.5 | 504 | 1/28/2020 |
1.1.4 | 484 | 1/28/2020 |
1.1.3 | 479 | 1/14/2020 |
1.1.2 | 462 | 1/13/2020 |
1.1.1 | 508 | 1/3/2020 |
1.1.0 | 841 | 12/3/2019 |
1.0.9 | 667 | 10/9/2019 |
1.0.8 | 493 | 10/8/2019 |
1.0.7 | 467 | 10/8/2019 |
1.0.6 | 493 | 10/8/2019 |
1.0.5 | 492 | 10/5/2019 |
1.0.4 | 479 | 10/5/2019 |
1.0.3 | 476 | 10/4/2019 |
1.0.2 | 547 | 9/26/2019 |
1.0.1 | 563 | 9/25/2019 |
1.0.0 | 598 | 9/25/2019 |