private static void Main(string[] args) { /* * Test class is described in Task_2.TestClass.cs */ // Create an instance of test class var test = new Test(); // Dictionary for storing the (name property or field) - (value) var dictionary = new Dictionary <string, string>(); // Completion dictionary.TryAdd("_dAta", "32,5"); dictionary.TryAdd("Auto", "This is auto"); dictionary.TryAdd("_number", "we32,5AS"); dictionary.TryAdd("Number", "32,456945"); // Attempt to bind test class with dictionary SimpleBinder.GetInstance(test.GetType(), dictionary); // Get binded object test = SimpleBinder.ObjectBinded; // View test class Console.WriteLine(test.ToString()); }
public static SimpleBinder GetInstance(Type type, Dictionary<string, string> dictionary) { if (_instance == null) _instance = new SimpleBinder(); ObjectBinded = Binder(type, dictionary); return _instance; }
static void Main(string[] args) { var sb = SimpleBinder.GetInstance(); var gold = (Metal)sb.Bind(typeof(Metal), new Dictionary <string, string> { { "Name", "Gold" }, { "Weight", "1000" }, { "Price", "150.555" } }); Console.WriteLine(gold); }
static SimpleBinder() { _sb = new SimpleBinder(); }