Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _1.LambadaExpressions
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string, string>> lambadaExpressions = new Dictionary<string, Dictionary<string, string>>();
- string inputLine = Console.ReadLine();
- while (inputLine != "lambada")
- {
- string[] inputParams = inputLine.Split(new[] {' ', '=', '>', '.'}, StringSplitOptions.RemoveEmptyEntries);
- if (inputParams.Length > 1)
- {
- string selector = inputParams[0];
- string selectorObject = inputParams[1];
- string property = inputParams[2];
- if (!lambadaExpressions.ContainsKey(selector))
- {
- lambadaExpressions.Add(selector, new Dictionary<string, string>());
- }
- lambadaExpressions[selector][selectorObject] = property;
- }
- else
- {
- lambadaExpressions = lambadaExpressions
- .ToDictionary(selector => selector.Key, x => x.Value
- .ToDictionary(selectorObject => selectorObject.Key,
- selectorObject => selectorObject.Key + "." + selectorObject.Value));
- }
- inputLine = Console.ReadLine();
- }
- foreach (var selector in lambadaExpressions)
- {
- foreach (var selectorObject in selector.Value)
- {
- Console.WriteLine("{0} => {1}.{2}", selector.Key, selectorObject.Key, selectorObject.Value);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement