static IO() { Mimes = new FreeDictionary <string, string>(); Mimes[".jpg"] = "image/jpeg"; Mimes[".jpeg"] = "image/jpeg"; Mimes[".png"] = "image/png"; Mimes[".bmp"] = "image/bmp"; Mimes[".gif"] = "image/gif"; Mimes[".html"] = "text/html"; Mimes[".json"] = "text/json"; Mimes[".txt"] = "text/plain"; // 来自IISExpress application.config Mimes[".doc"] = "application/msword"; Mimes[".docx"] = "application/application/vnd.openxmlformats-officedocument.wordprocessingml.document"; Mimes[".xls"] = "application/vnd.ms-excel"; Mimes[".xlsx"] = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Mimes[".ppt"] = "application/vnd.ms-powerpoint"; Mimes[".pptx"] = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; Mimes[".exe"] = "application/octet-stream"; Mimes[".pdf"] = "application/pdf"; Mimes[".js"] = "application/x-javascript"; Mimes[".mp3"] = "audio/mp3"; Mimes[".mp4"] = "vedio/mp4"; // Mimes[".cdr"] = "application/x-cdr"; }
/// <summary>Parse querystring to dict(eg. id=1&name=Kevin)</summary> /// <param name="text">Querystring, eg. id=1&name=Kevin</param> public static FreeDictionary <string, string> ParseDict(this string text) { var dict = new FreeDictionary <string, string>(); if (text.IsEmpty()) { return(dict); } var regex = new Regex(@"(^|&)?(\w+)=([^&]+)(&|$)?", RegexOptions.Compiled); var matches = regex.Matches(text); foreach (Match match in matches) { var key = match.Result("$2"); var value = match.Result("$3"); dict.Add(key, value); } return(dict); }