static void Main(string[] args) { //App name, this is what the folder will be called in Appdata\Local\<appNameSpace> string appNamespace = "Json2Config.Net"; //Creates the config folder & config.json ConfigManager burgerCfg = new ConfigManager(appNamespace, "burgerCfg"); ConfigManager securityCfg = new ConfigManager(appNamespace, "securityCfg"); //Get the objects ready Store myStore = new Store(); myStore.Name = "Bobs Burgers"; Product product1 = new Product() { Name = "Cheese Burgers", Price = 7.99 }; Product product2 = new Product() { Name = "Pizza", Price = 12.49 }; myStore.Products.Add(product1); myStore.Products.Add(product2); //Save the objects! burgerCfg.SaveConfig(myStore); Company myCompany = new Company(); myCompany.CompanyId = 1; myCompany.CompanyName = "Jacks Security Folk"; Client client1 = new Client() { ClientId = 1, Name = "Bobs Burgers", WebsiteUrl = "BobsBurgers.biz" }; myCompany.Clients.Add(client1); securityCfg.SaveConfig(myCompany); }
private async static void CallApi() { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:58300/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var gizmo = new Product() { Name = "Gizmo", Price = 100, Category = "Widget" }; HttpResponseMessage response = await client.PostAsJsonAsync("api/sherlock", gizmo); } }