コード例 #1
0
        private void ProxyServer_BeforeRequest(object sender, Titanium.Web.Proxy.EventArguments.SessionEventArgs e)
        {
            var    request = e.ProxySession.Request;
            string path    = request.RequestUri.PathAndQuery;

            if (path.Contains(".mp3"))
            {
                string[] substrings = path.Split('/');
                switch (substrings[3])
                {
                case "titlecall":
                    ToolViewModel.UpdateText(DialogueTranslator.Add(DialogueType.Titlecall, substrings[4], substrings[5].Split('.')[0]));
                    break;

                case "kc9999":
                    ToolViewModel.UpdateText(DialogueTranslator.Add(DialogueType.NPC, "npc", substrings[4].Split('.')[0]));
                    break;

                default:
                    ToolViewModel.UpdateText(DialogueTranslator.Add(DialogueType.Shipgirl, substrings[3].Substring(2), substrings[4].Split('.')[0]));
                    break;
                }
                if (request.RequestHeaders.Where(h => h.Name == "If-Modified-Since").Count() > 0)
                {
                    if (cacheControl.ContainsKey(path))
                    {
                        if (cacheControl[path].Item2 < DateTime.Now)
                        {
                            return;
                        }
                        else
                        {
                            e.NotModified(cacheControl[path].Item1);
                        }
                    }
                }
            }
        }