Какую из двух приведенных ниже программ труднее понять без комментариев?
using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Web;
class Program
{
static void Main(string[] args) {
try {
if (args.Length == 1) {
WebRequest request =
WebRequest.Create("http://www.comeaucomputing.com/pcgi-bin/compiler.cgi");
request.Method = "POST";
using (StreamWriter requestWriter = new StreamWriter(request.GetRequestStream())) {
requestWriter.Write("Tused=-tused&Strict=-A&Version=433&Comment=");
using (StreamReader sourceTextReader = new StreamReader(args[0]))
requestWriter.Write(HttpUtility.UrlEncode(sourceTextReader.ReadToEnd()));
}
using (StreamReader responseReader =
new StreamReader(request.GetResponse().GetResponseStream()))
HttpUtility.HtmlDecode(new Regex("<pre>([^<]*)</pre>")
.Match(responseReader.ReadToEnd()).Groups[1].Value, Console.Out);
}
else
Console.WriteLine("Syntax: comoc filename");
}
catch (Exception e) {
Console.WriteLine(e.Message);
}
}
}
using System;
using System.IO;
using System.Net;
using System.Text.RegularExpressions;
using System.Web;
class Program
{
static void Main(string[] args) {
try {
if (args.Length == 1) {
string filename = args[0];
string sourceText;
using (StreamReader sourceTextReader = new StreamReader(filename))
sourceText = sourceTextReader.ReadToEnd();
const string compilerUri = "http://www.comeaucomputing.com/pcgi-bin/compiler.cgi";
WebRequest request = WebRequest.Create(compilerUri);
request.Method = "POST";
using (StreamWriter requestWriter = new StreamWriter(request.GetRequestStream())) {
const string postDataConstPart = "Tused=-tused&Strict=-A&Version=433&Comment=";
requestWriter.Write(postDataConstPart);
requestWriter.Write(HttpUtility.UrlEncode(sourceText));
}
WebResponse response = request.GetResponse();
string html;
using (StreamReader responseReader = new StreamReader(response.GetResponseStream()))
html = responseReader.ReadToEnd();
Regex compilerOutputRegex = new Regex("<pre>([^<]*)</pre>");
string compilerOutput = compilerOutputRegex.Match(html).Groups[1].Value;
HttpUtility.HtmlDecode(compilerOutput, Console.Out);
}
else
Console.WriteLine("Syntax: comoc filename");
}
catch (Exception e) {
Console.WriteLine(e.Message);
}
}
}