Advertisement
Mitax

Testing Lambda

Mar 14th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _01.Lambada_Expressions
  8. {
  9. class LambdaExpressions
  10. {
  11. static void Main(string[] args)
  12. {
  13. var line = Console.ReadLine()
  14. .Split(new[] { ' ', '=', '>', '.' }, StringSplitOptions.RemoveEmptyEntries);
  15.  
  16. Dictionary<string, Dictionary<List<string>, string>> registry =
  17. new Dictionary<string, Dictionary<List<string>, string>>();
  18.  
  19. Dictionary<string, Dictionary<List<string>, string>> orderedRegistry =
  20. new Dictionary<string, Dictionary<List<string>, string>>();
  21.  
  22. var selector = "";
  23. var selectorObject = new List<string>();
  24. var property = "";
  25. var danceCounter = 0;
  26.  
  27. while (line[0] != "lambada")
  28. {
  29. if (line[0] == "dance")
  30. {
  31. danceCounter++;
  32. }
  33. else
  34. {
  35. selector = line[0];
  36. selectorObject.Add(line[1]);
  37. property = line[2];
  38.  
  39. if (!registry.ContainsKey(selector))
  40. {
  41. registry.Add(selector, new Dictionary<List<string>, string>());
  42. }
  43. registry[selector][selectorObject] = property;
  44. }
  45.  
  46. line = Console.ReadLine()
  47. .Split(new[] { ' ', '=', '>', '.' }, StringSplitOptions.RemoveEmptyEntries);
  48. }
  49. foreach (var item in registry.Values)
  50. {
  51. Console.WriteLine($"{item.Keys} => {String.Join(" ", item.Values)}" );
  52. }
  53. Console.WriteLine(danceCounter);
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement