public static HttpWebRequest GetRequest(string request, TlpdDatabase db) { var encoded = System.Uri.EscapeDataString(request); var requestString = string.Format("text={0}&mode=tlpd-{1}", encoded, db.TlpdizeMode); System.Net.ServicePointManager.Expect100Continue = false; var webRequest = (HttpWebRequest)WebRequest.Create("http://www.teamliquid.net/tlpd/tlpdize.php"); webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.ContentLength = requestString.Length; webRequest.Accept = "*/*"; webRequest.Timeout = 10000; using (var stream = webRequest.GetRequestStream()) using (var sw = new StreamWriter(stream)) { sw.Write(requestString); } return webRequest; }
public static string Request(string request, TlpdDatabase db) { var webRequest = GetRequest(request, db); var response = webRequest.GetResponse(); using (var stream = response.GetResponseStream()) using (var sr = new StreamReader(stream)) { return sr.ReadToEnd(); } }
public string GetLinkUrl(Place p, TlpdDatabase tlpd) { var linkStyleIndex = tb.GetStyleIndexMask(new Style[] { linkStyle }); var tlpdStyleIndex = tb.GetStyleIndexMask(new Style[] { linkTlpdStyle }); string text = tb.GetRange(p, p).GetFragment(@"[\S]").Text; if ((tb[p].style & linkStyleIndex) != 0) { return "$" + ResolveIncludeFile(text); } if ((tb[p].style & tlpdStyleIndex) != 0) { TlpdEntity entity = Tlpd.Parse(text, true); if (string.IsNullOrEmpty(entity.Database)) entity.Database = tlpd.Url; return entity.Url; } return text; }