Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new shared counter.
 /// </summary>
 /// <param name="runtime">The machine runtime.</param>
 /// <param name="value">The initial value.</param>
 public static ISharedCounter Create(IMachineRuntime runtime, int value = 0)
 {
     if (runtime is ProductionRuntime)
     {
         return(new ProductionSharedCounter(value));
     }
     else if (runtime is SystematicTestingRuntime testingRuntime)
     {
         return(new MockSharedCounter(value, testingRuntime));
     }
     else
     {
         throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + ".");
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new shared dictionary.
 /// </summary>
 /// <param name="comparer">The key comparer.</param>
 /// <param name="runtime">The machine runtime.</param>
 public static ISharedDictionary <TKey, TValue> Create <TKey, TValue>(IEqualityComparer <TKey> comparer, IMachineRuntime runtime)
 {
     if (runtime is ProductionRuntime)
     {
         return(new ProductionSharedDictionary <TKey, TValue>(comparer));
     }
     else if (runtime is SystematicTestingRuntime testingRuntime)
     {
         return(new MockSharedDictionary <TKey, TValue>(comparer, testingRuntime));
     }
     else
     {
         throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + ".");
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new shared register.
 /// </summary>
 /// <param name="runtime">The machine runtime.</param>
 /// <param name="value">The initial value.</param>
 public static ISharedRegister <T> Create <T>(IMachineRuntime runtime, T value = default)
     where T : struct
 {
     if (runtime is ProductionRuntime)
     {
         return(new ProductionSharedRegister <T>(value));
     }
     else if (runtime is SystematicTestingRuntime testingRuntime)
     {
         return(new MockSharedRegister <T>(value, testingRuntime));
     }
     else
     {
         throw new RuntimeException("Unknown runtime object of type: " + runtime.GetType().Name + ".");
     }
 }