Advertisement
Angellova

LambadaExpressions

Mar 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 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 _1.LambadaExpressions
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Dictionary<string, Dictionary<string, string>> lambadaExpressions = new Dictionary<string, Dictionary<string, string>>();
  14.  
  15. string inputLine = Console.ReadLine();
  16.  
  17. while (inputLine != "lambada")
  18. {
  19. string[] inputParams = inputLine.Split(new[] {' ', '=', '>', '.'}, StringSplitOptions.RemoveEmptyEntries);
  20.  
  21. if (inputParams.Length > 1)
  22. {
  23. string selector = inputParams[0];
  24. string selectorObject = inputParams[1];
  25. string property = inputParams[2];
  26.  
  27. if (!lambadaExpressions.ContainsKey(selector))
  28. {
  29. lambadaExpressions.Add(selector, new Dictionary<string, string>());
  30. }
  31.  
  32. lambadaExpressions[selector][selectorObject] = property;
  33. }
  34. else
  35. {
  36. lambadaExpressions = lambadaExpressions
  37. .ToDictionary(selector => selector.Key, x => x.Value
  38. .ToDictionary(selectorObject => selectorObject.Key,
  39. selectorObject => selectorObject.Key + "." + selectorObject.Value));
  40. }
  41.  
  42. inputLine = Console.ReadLine();
  43. }
  44.  
  45. foreach (var selector in lambadaExpressions)
  46. {
  47. foreach (var selectorObject in selector.Value)
  48. {
  49. Console.WriteLine("{0} => {1}.{2}", selector.Key, selectorObject.Key, selectorObject.Value);
  50. }
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement