static void Main() { ICountDownNotifier[] array = new ICountDownNotifier[] { new MethodClass(), new AnonymousClass(), new LambdaClass() }; CountDownTimer[] timers = new[] { new CountDownTimer("Чтение задания"), new CountDownTimer("Выполнение задания"), new CountDownTimer("Проверка задания") }; //Ввод длительности таймеров int[] time = new int[3]; for (int i = 0; i < 3; i++) { Console.WriteLine($"Введите продолжительность {i + 1}го таймера в секундах:"); //Ввод чисел. Отбрасывает отрицательные значения, и значения, которые приведут к overflow while (!int.TryParse(Console.ReadLine(), out time[i]) || time[i] < 0 || time[i] >= int.MaxValue / 1000) { Console.WriteLine("Неверный ввод"); } } //Запуск таймеров Console.WriteLine("Запуск:\n"); for (int i = 0; i < timers.Length; i++) { //Подписка на события array[i].Init(timers[i]); try { //Запуск таймера array[i].Run(time[i]); } catch (OverflowException) { Console.WriteLine("Timer overflow. Skipping Timer."); } } //Демонстрация подписки нескольких классов на один таймер Console.WriteLine("Демонстрация подписки нескольких классов на один таймер:"); CountDownTimer timer = new CountDownTimer("ОБЩИЙ"); ICountDownNotifier item1 = new MethodClass(); ICountDownNotifier item2 = new LambdaClass(); item1.Init(timer); item2.Init(timer); item1.Run(10); Console.ReadLine(); }
public void LoadBuiltinClasses() { classes["Int"] = new IntClass(); classes["Float"] = new FloatClass(); classes["Boolean"] = new BooleanClass(); classes["String"] = new StringClass(); classes["Char"] = new CharClass(); classes["Byte"] = new ByteClass(); classes["Message"] = new MessageClass(); classes["Unassigned"] = new UnassignedClass(); classes["Tuple"] = new TupleClass(); classes["NameValue"] = new NameValueClass(); classes["Lambda"] = new LambdaClass(); classes["Void"] = new VoidClass(); classes["Some"] = new SomeClass(); classes["None"] = new NoneClass(); classes["Array"] = new ArrayClass(); classes["Iterator"] = new IteratorClass(); classes["LazyIterator"] = new LazyIteratorClass(); classes["StreamIterator"] = new StreamIteratorClass(); classes["Any"] = new AnyClass(); classes["Placeholder"] = new PlaceholderClass(); classes["Range"] = new RangeClass(); classes["Dictionary"] = new DictionaryClass(); classes["Container"] = new ContainerClass(); classes["Unmatched"] = new UnmatchedClass(); classes["Complex"] = new ComplexClass(); classes["Rational"] = new RationalClass(); classes["Long"] = new LongClass(); classes["Lazy"] = new LazyClass(); classes["YieldingInvokable"] = new YieldingInvokableClass(); classes["Del"] = new DelClass(); classes["Slice"] = new SliceClass(); classes["End"] = new EndClass(); classes["List"] = new ListClass(); classes["Arguments"] = new ArgumentsClass(); classes["Symbol"] = new SymbolClass(); classes["Infinity"] = new InfinityClass(); classes["OpenRange"] = new OpenRangeClass(); classes["KeyValue"] = new KeyValueClass(); classes["Regex"] = new RegexClass(); classes["Pattern"] = new PatternClass(); classes["PackageFunction"] = new PackageFunctionClass(); classes["Sys"] = new SysClass(); classes["Math"] = new MathClass(); classes["RuntimeFunction"] = new RuntimeFunctionClass(); classes["Reference"] = new ReferenceClass(); classes["Group"] = new RegexGroupClass(); classes["Match"] = new RegexMatchClass(); classes["Date"] = new DateClass(); classes["Interval"] = new IntervalClass(); classes["TypeConstraint"] = new TypeConstraintClass(); classes["ByteArray"] = new ByteArrayClass(); classes["Selector"] = new SelectorClass(); classes["Number"] = new NumberClass(); classes["Collection"] = new CollectionClass(); classes["TextFinding"] = new TextFindingClass(); classes["SkipTake"] = new SkipTakeClass(); classes["Constructor"] = new ConstructorClass(); classes["MutString"] = new MutStringClass(); classes["Error"] = new ErrorClass(); classes["Success"] = new SuccessClass(); classes["Failure"] = new FailureClass(); classes["Optional"] = new OptionalClass(); classes["Result"] = new ResultClass(); classes["Monad"] = new MonadClass(); classes["Unit"] = new UnitClass(); classes["YieldReturn"] = new YieldReturnClass(); classes["Index"] = new IndexClass(); classes["Cycle"] = new CycleClass(); classes["Set"] = new SetClass(); }