private void ReplaceResources(object sender, ResponseInterceptedEventArgs e) { string absoluteUri = e.Response.ResponseUri.AbsoluteUri; if (ResourceReplacements.ContainsKey(absoluteUri)) { var httpResponse = (HttpWebResponse)e.Response; string replacementUrl = ResourceReplacements[absoluteUri]; if (httpResponse.StatusCode == HttpStatusCode.TemporaryRedirect) { ResourceReplacements.Remove(absoluteUri); absoluteUri = httpResponse.Headers[HttpResponseHeader.Location]; ResourceReplacements[absoluteUri] = replacementUrl; return; } if (replacementUrl.StartsWith("http")) { using (var webClient = new WebClient()) e.Payload = webClient.DownloadData(replacementUrl); } else { e.Payload = File.ReadAllBytes(replacementUrl); } ResourceReplacements.Remove(absoluteUri); if (ResourceReplacements.Count < 1) { Halt(); SetStatus(TanjiState.StandingBy); } } }
private void CoTVariablesVw_ItemChecked(object sender, ItemCheckedEventArgs e) { string name = e.Item.Text; string value = e.Item.SubItems[1].Text; bool updateValue = (e.Item.Checked && !string.IsNullOrWhiteSpace(value)); if (updateValue) { ResourceReplacements[name] = value; } else if (ResourceReplacements.ContainsKey(name)) { ResourceReplacements.Remove(name); } }