50
1
using System;
2
using MemoizR;
3
using System.Threading.Tasks;
4
5
public class Program
6
{
7
public static async Task Main()
8
{
9
var f = new MemoFactory();
10
var one = f.CreateSignal(2);
11
var two = f.CreateSignal(2);
12
var squareOne = f.CreateMemoizR(async () =>
13
{
14
var value = await one.Get();
15
Console.WriteLine($"Square One: {value}");
16
return Math.Pow(value, 2);
17
});
18
var squareTwo = f.CreateMemoizR(async () =>
19
{
20
var value = await two.Get();
21
Console.WriteLine($"Square Two: {value}");
22
return Math.Pow(value, 2);
23
});
24
var final = f.CreateMemoizR(async () =>
Cached Result
Serialized configuration:
{
"name": "simple",
"value": 101,
"type": "Simple1"
}
Re-serialized configuration:
{
"name": "simple",
"value": 101,
"type": "Simple1"
}
Configuration serialized and de-serialized successfully.
Serialized configuration:
{
"name": "complex",
"value": 202,
"type": {
"Optional1": {
"setting1": "optional1"
}
}
}
Re-serialized configuration:
{
"name": "complex",
"value": 202,
"type": {
"Optional1": {
"setting1": "optional1"
}
}
}
Configuration serialized and de-serialized successfully.
Serialized configuration:
{
"name": "cpmplex",
"value": 202,
"type": {
"Optional2": null
}
}
Re-serialized configuration:
{
"name": "cpmplex",
"value": 202,
"type": {
"Optional2": null
}
}
Configuration serialized and de-serialized successfully.
{
"name": "simple",
"value": 101,
"type": "Simple1"
}
Re-serialized configuration:
{
"name": "simple",
"value": 101,
"type": "Simple1"
}
Configuration serialized and de-serialized successfully.
Serialized configuration:
{
"name": "complex",
"value": 202,
"type": {
"Optional1": {
"setting1": "optional1"
}
}
}
Re-serialized configuration:
{
"name": "complex",
"value": 202,
"type": {
"Optional1": {
"setting1": "optional1"
}
}
}
Configuration serialized and de-serialized successfully.
Serialized configuration:
{
"name": "cpmplex",
"value": 202,
"type": {
"Optional2": null
}
}
Re-serialized configuration:
{
"name": "cpmplex",
"value": 202,
"type": {
"Optional2": null
}
}
Configuration serialized and de-serialized successfully.