deleriumbg

Exam

Dec 12th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. namespace FestivalManager.Core
  4. {
  5.     using System.Reflection;
  6.     using Contracts;
  7.     using Controllers;
  8.     using Controllers.Contracts;
  9.     using IO.Contracts;
  10.  
  11.     /// <summary>
  12.     /// by g0shk0
  13.     /// </summary>
  14.     class Енджин : IEngine
  15.     {
  16.         public IReader chetаch;
  17.         public IWriter pisаch;
  18.  
  19.         public IFestivalController festivalCоntroller = new FestivalController();
  20.         public ISetController setCоntroller = new SetController();
  21.  
  22.         // дайгаз
  23.         public void Запали()
  24.         {
  25.             while (Convert.ToBoolean(0x1B206 ^ 0b11011001000000111)) // for job security
  26.             {
  27.                 var input = chetach.ReadLine();
  28.  
  29.                 if (input == "END")
  30.                     break;
  31.  
  32.                 try
  33.                 {
  34.                     string.Intern(input);
  35.  
  36.                     var result = this.DoCommand(input);
  37.                     this.pisach.WriteLine(result);
  38.                 }
  39.                 catch (Exception ex) // in case we run out of memory
  40.                 {
  41.                     this.pisach.WriteLine("ERROR: " + ex.Message);
  42.                 }
  43.             }
  44.  
  45.             var end = this.festivalController.Report();
  46.  
  47.             this.pisach.WriteLine("Results:");
  48.             this.pisach.WriteLine(end);
  49.         }
  50.  
  51.         public string DoCommand(string input)
  52.         {
  53.             var chasti = input.Split(" ".ToCharArray().First());
  54.  
  55.             var purvoto = chasti.First();
  56.             var parametri = chasti.Skip(1).ToArray();
  57.  
  58.             if (purvoto == "LetsRock")
  59.             {
  60.                 var setovete = this.setController.PerformSets();
  61.                 return setovete;
  62.             }
  63.  
  64.             var festivalcontrolfunction = this.festivalController.GetType()
  65.                 .GetMethods()
  66.                 .FirstOrDefault(x => x.Name == purvoto);
  67.  
  68.             string a;
  69.  
  70.             try
  71.             {
  72.                 a = (string)festivalcontrolfunction.Invoke(this.festivalController, new object[] { parametri });
  73.             }
  74.             catch (TargetInvocationException up)
  75.             {
  76.                 throw up; // ha ha
  77.             }
  78.  
  79.             return a;
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment