Home > C#, Google > Google Closure Compiler in C#

Google Closure Compiler in C#

Mads Kristensen has created a C# class for using Google Closure Compiler.

This class is very easy but very useful:

public string Compress(string file)
{
  string source = File.ReadAllText(file);
  XmlDocument xml = CallApi(source);
  return xml.SelectSingleNode("//compiledCode").InnerText;
}

private static XmlDocument CallApi(string source)
{
  using (WebClient client = new WebClient())
  {
    client.Headers.Add("content-type", "application/x-www-form-urlencoded");
    string data = string.Format(PostData, HttpUtility.UrlEncode(source));
    string result = client.UploadString(ApiEndpoint, data);

    XmlDocument doc = new XmlDocument();
    doc.LoadXml(result);
    return doc;
  }
}

For information and for download the complite code, read Mads Kristensen’ s post.

Abount Closure Compiler project.

Categorie:C#, Google Tag: , ,
  1. Nessun commento ancora...
  1. Nessun trackback ancora...