2using System.Collections.Generic;
15 [CollectionName(
"StateMachineCurrentStates")]
17 [ArchivingTime(nameof(ArchiveDays))]
18 [Index(
"StateMachineId")]
21 private readonly
object synchObj =
new object();
22 private Dictionary<string, CurrentStateVariable> variablesByName;
23 private Dictionary<CaseInsensitiveString, bool> sourcesByName;
47 public string State {
get;
set; }
109 this.variablesByName =
null;
113 if (this.variablesByName is
null)
114 this.SortVariablesLocked();
128 this.VariableValues = Updated;
129 this.variablesByName[Name] = V;
144 Variables.ContextVariables = Machine;
167 if (this.variablesByName is
null)
168 this.SortVariablesLocked();
170 return this.variablesByName.TryGetValue(Name, out
Variable);
174 private void SortVariablesLocked()
176 Dictionary<string, CurrentStateVariable> Sorted =
new Dictionary<string, CurrentStateVariable>();
181 Sorted[Variable2.
Name] = Variable2;
184 this.variablesByName = Sorted;
203 this.sourcesByName =
null;
209 if (this.sourcesByName is
null)
210 this.SortSourcesLocked();
212 if (this.sourcesByName.ContainsKey(Name))
218 Array.Copy(this.
Sources, 0, Updated, 0, c);
221 this.Sources = Updated;
222 this.sourcesByName[Name] =
true;
241 if (!(this.sourcesByName is
null) && !this.sourcesByName.Remove(Name))
244 int i = Array.IndexOf(this.
Sources, Name);
253 Array.Copy(this.
Sources, 0, Updated, 0, i);
256 Array.Copy(this.
Sources, i + 1, Updated, i, c - i - 1);
258 this.Sources = Updated;
273 if (this.sourcesByName is
null)
274 this.SortSourcesLocked();
276 return this.sourcesByName.ContainsKey(Name);
280 private void SortSourcesLocked()
282 Dictionary<CaseInsensitiveString, bool> Sorted =
new Dictionary<CaseInsensitiveString, bool>();
287 Sorted[Source2] =
true;
290 this.sourcesByName = Sorted;
Implements an HTTP server.
static Variables CreateVariables()
Creates a new collection of variables, that contains access to the global set of variables.
Represents a case-insensitive string.
int Length
Gets the number of characters in the current CaseInsensitiveString object.
Contains information about a variable.
string Name
Name of variable.
static int CalcArchiveDays(DateTime Expires, Duration? ArchiveReq, Duration? ArchiveOpt)
Calculates the number of days an object should be archived in the ledger.
Class representing the current state of a state machine.
string StateMachineId
ID of State-Machine.
bool ContainsSource(CaseInsensitiveString Name)
Checks if a source exists.
string ObjectId
Object ID of current state.
bool IsRunning
If state-machine is running.
CurrentStateVariable[] VariableValues
Current variable values.
Duration? ArchiveRequired
Duration after which token expires, the token is required to be archived.
Duration? ArchiveOptional
Duration after which token expires, and the required archiving time, the token can optionally be arch...
CaseInsensitiveString[] Sources
Approved sources.
int ArchiveDays
Number of days to archive field.
bool HasEnded
If state-machine has ended.
DateTime Expires
When state-machine expires
bool TryGetVariable(string Name, out CurrentStateVariable Variable)
Tries to get a state variable, given its name.
void SetVariable(string Name, object Value)
Sets a variable
Variables GetVariables(StateMachine Machine)
Gets a new variable collection containing the current state variables.
bool AddSource(CaseInsensitiveString Name)
Adds a source
string State
ID of current state in state-machine. Empty State = State-machine has ended.
bool RemoveSource(CaseInsensitiveString Name)
Removes a source
CurrentState()
Class representing the current state of a state machine.
Class representing a persisted state-machine variable value.
Class representing a state machine.
TypeNameSerialization
How the type name should be serialized.
Represents a duration value, as defined by the xsd:duration data type: http://www....