public ActionResult Index() { var script = new StringBuilder() .AddRelative("~/scripts/privacyController.js"); Response.ContentType = "text/javascript"; IDictionary<string, bool> result = new Dictionary<string, bool>(); var loader = new PrivacyLoader(Request); var source = loader.Load(); if (!string.IsNullOrWhiteSpace(source)) using (var reader = new PrivacyReader(source)) result = reader.ReadAll(); var policies = expectedPrivacies.Select(e => new PrivacySettingViewModel { Name = e, Setting = result.ContainsKey(e) ? result[e] : (bool?)null }); var userPolicies = GetSettings().Select(e => new PrivacySettingViewModel { Name = e.Key, Setting = e.Value }); return View(new PrivacyScriptViewModel { Policies = policies, Script = script.ToString(), UserSettings = userPolicies }); }
public void Can_parse() { //Arrange var privacy = @" share info with third party: no track for statistical: yes track for advertisement: no"; IDictionary<string, bool> result; //Act using (var reader = new PrivacyReader(privacy)) result = reader.ReadAll(); //Assert Assert.That(result["track for statistical"]); }
public ActionResult SiteInfo(Uri url) { if (url == null) return HttpNotFound(); IDictionary<string, bool> result; var loader = new PrivacyLoader(Request); var source = loader.Load(); if (string.IsNullOrWhiteSpace(source)) { result = new Dictionary<string, bool>(); } else { using (var reader = new PrivacyReader(source)) result = reader.ReadAll(); } var policies = expectedPrivacies.Select(e => new PrivacySettingViewModel { Name = e, Setting = result.ContainsKey(e) ? result[e] : (bool?)null }); var userPolicies = GetSettings().Select(e => new PrivacySettingViewModel { Name = e.Key, Setting = e.Value }); return View(new PrivacytViewModel {Policies = policies, UserSettings = userPolicies, BaseSettings = expectedPrivacies, Site = url}); }