Secured statemachine
This commit is contained in:
parent
4ab6ffd890
commit
188d8f48e3
@ -81,20 +81,24 @@ public class StateMachine
|
||||
|
||||
public IEnumerable<string> GetIds()
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
lock (Mutex)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
foreach (var kv in Implementation)
|
||||
yield return kv.Key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<Triplet> Get()
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
lock (Mutex)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
foreach (var kv in Implementation)
|
||||
foreach (var kvv in kv.Value)
|
||||
yield return new Triplet
|
||||
@ -104,17 +108,24 @@ public class StateMachine
|
||||
value = kvv.Value.Value,
|
||||
LastFlush = kvv.Value.When
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<Triplet> Get(string key)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
Dictionary<string, ImplValue> dic;
|
||||
|
||||
|
||||
lock (Mutex)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
if (!Implementation.TryGetValue(key, out dic))
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
||||
foreach(var kv in dic)
|
||||
yield return new Triplet
|
||||
@ -128,13 +139,19 @@ public class StateMachine
|
||||
|
||||
public DateTime? GetLastUpdate(string key)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
Dictionary<string, ImplValue> dic;
|
||||
|
||||
|
||||
|
||||
lock (Mutex)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
if (!Implementation.TryGetValue(key, out dic))
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
DateTime mostrecent = DateTime.MinValue;
|
||||
foreach (var kv in dic)
|
||||
@ -149,13 +166,16 @@ public class StateMachine
|
||||
|
||||
public object? Get(string key, string predicate)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
lock (Mutex)
|
||||
{
|
||||
if (!Populated)
|
||||
PopulateWithHistory().Wait();
|
||||
|
||||
if (Implementation.TryGetValue(key, out var value))
|
||||
if (value.TryGetValue(predicate, out var ret))
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user