static void Main(string[] args) { TVMPreferences tvmPrefs = new TVMPreferences { contrastTheme = "yellow-black", fontSize = "big", fontFace = "Comic Sans", buttonSize = "big", timeOut = "long", language = "de" }; TVMSettings t2 = new TVMSettings(tvmPrefs); string x = JsonConvert.SerializeObject(t2); Console.WriteLine(x + " ConsoleGET.Program"); x = "{\"de.fraunhofer.iao.C4A-TVM\":{\"contrastTheme\": \"yellow-black\", \"fontSize\": \"default\", \"fontFace\": \"default\", \"buttonSize\": \"default\", \"timeOut\": \"default\", \"language\": \"default\"}}"; Console.WriteLine("input string" + x); TVMSettings t1 = JsonConvert.DeserializeObject<TVMSettings>(x); printTVMSettings(t1); Console.ReadLine(); }
public static void printTVMSettings(TVMSettings t) { String c = t.TVMPreferences.contrastTheme; String fs = t.TVMPreferences.fontSize; String ff = t.TVMPreferences.fontFace; String bs = t.TVMPreferences.buttonSize; String to = t.TVMPreferences.timeOut; String l = t.TVMPreferences.language; if (fs != null) { Console.WriteLine("fs = " + fs); } else { Console.WriteLine("fs = null"); } if (c != null) { Console.WriteLine("c = " + c); } else { Console.WriteLine("c = null"); } if (ff != null) { Console.WriteLine("ff = " + ff); } else { Console.WriteLine("ff = null"); } if (fs != null) { Console.WriteLine("fs = " + fs); } else { Console.WriteLine("fs = null"); } if (bs != null) { Console.WriteLine("bs = " + bs); } else { Console.WriteLine("bs = null"); } if (to != null) { Console.WriteLine("to = " + to); } else { Console.WriteLine("to = null"); } if (l != null) { Console.WriteLine("l = " + l); } else { Console.WriteLine("l = null"); } }