Skip to content

Instantly share code, notes, and snippets.

@sombochea
Created March 27, 2019 09:44
Show Gist options
  • Save sombochea/6522b4f1d2fcb5aea86794043cfbcdad to your computer and use it in GitHub Desktop.
Save sombochea/6522b4f1d2fcb5aea86794043cfbcdad to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
public class User {
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class Company {
public string Name { get; set; }
public string City { get; set; }
}
public class TemplateParser {
// To Implement
}
class Solution {
public string solution(string S) {
var templateParser = new TemplateParser()
.Register<User>("{{UserFirstName}}", (user) => user.FirstName)
.Register<User>("{{UserLastName}}", (user) => user.LastName)
.Register<Company>("{{CompanyName}}", (company) => company.Name)
.Register<Company>("{{CompanyCity}}", (company) => company.City);
var objects = new object[] {
new User() { FirstName = "John", LastName = "Doe" },
new Company() { Name = "ABC Company", City = "Quito" }
};
return templateParser.Parse(S, objects);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment