public ActionResult Settings(GlobalSettings settings) { JsonNetFormatter.Formatting = settings.Indent ? Formatting.Indented : Formatting.None; JsonNetFormatter.Settings.DefaultValueHandling = settings.RemoveDefaults ? DefaultValueHandling.Ignore : DefaultValueHandling.Include; JsonNetFormatter.Settings.NullValueHandling = settings.RemoveNulls ? NullValueHandling.Ignore : NullValueHandling.Include; JsonNetFormatter.Settings.DateFormatHandling = settings.UseIsoFormat ? DateFormatHandling.IsoDateFormat : DateFormatHandling.MicrosoftDateFormat; JsonNetFormatter.Settings.ContractResolver = settings.UseCamelCase ? new CamelCasePropertyNamesContractResolver() : new DefaultContractResolver(); SystemConstants.TemporaryTokenExpiryTimeInMinutes = settings.TemporaryTokenExpiryTimeInMinutes; using (var sw = new StreamWriter(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data", "iLoopAPISettings.txt"), false)) sw.Write(JsonConvert.SerializeObject(settings, Formatting.Indented)); return null; }
public ActionResult Settings() { ViewBag.Title = "iLoop API Settings"; var globalSettings = new GlobalSettings { Indent = JsonNetFormatter.Formatting == Formatting.Indented, UseIsoFormat = JsonNetFormatter.Settings.DateFormatHandling == DateFormatHandling.IsoDateFormat, RemoveDefaults = JsonNetFormatter.Settings.DefaultValueHandling == DefaultValueHandling.Ignore, RemoveNulls = JsonNetFormatter.Settings.NullValueHandling == NullValueHandling.Ignore, UseCamelCase = JsonNetFormatter.Settings.ContractResolver is CamelCasePropertyNamesContractResolver, TemporaryTokenExpiryTimeInMinutes = SystemConstants.TemporaryTokenExpiryTimeInMinutes }; return View(globalSettings); }