public string GetRemoteResourceContent(CombinatorResource resource)
 {
     using (var wc = new WebClient())
     {
         var byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
         var content = new UTF8Encoding(false).GetString(wc.DownloadData(resource.AbsoluteUrl));
         if (content.StartsWith(byteOrderMarkUtf8)) // Stripping "?"s from the beginning of css commments "/*"
         {
             content = content.Remove(0, byteOrderMarkUtf8.Length);
         }
         return content;
     }
 }
Exemplo n.º 2
0
		public void Do()
		{
			//
			string utf8Bom = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());

			//
			appUrl = url;
			appPath = ".\\";
			appName = url.Substring(url.LastIndexOf('/') + 1);
			appData = HttpHelper.GetData(appUrl);
			appXml = new System.Text.UTF8Encoding(false).GetString(appData);
			if (appXml.StartsWith(utf8Bom)) appXml = appXml.Remove(0, utf8Bom.Length);
			Console.WriteLine(string.Format("load {0}", appUrl));

			//
			string manifestCodebase = ParseAppXml(appXml);

			//
			manifestUrl = appUrl.Substring(0, url.LastIndexOf('/') + 1) + manifestCodebase.Replace('\\', '/');
			manifestPath = manifestCodebase.Substring(0, manifestCodebase.LastIndexOf('\\') + 1);
			manifestName = manifestCodebase.Substring(manifestCodebase.LastIndexOf('\\') + 1);
			manifestData = HttpHelper.GetData(manifestUrl);
			manifestXml = System.Text.Encoding.UTF8.GetString(manifestData);
			if (manifestXml.StartsWith(utf8Bom)) manifestXml = manifestXml.Remove(0, utf8Bom.Length);
			Console.WriteLine(string.Format("load {0}", manifestUrl));

			//
			List<Item> items = ParseManifestXml(manifestXml);

			//
			string taskXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
			taskXml += "<files>\r\n";
			for (int i = 0; i < items.Count; i++)
			{
				string name = items[i].name;
				int size = items[i].size;
				string filePath = manifestPath;
				string fileName = name;
				if (name.LastIndexOf('\\') > 0)
				{
					filePath += name.Substring(0, name.LastIndexOf('\\') + 1);
					fileName = name.Substring(name.LastIndexOf('\\') + 1);
				}
				string fileUrl = manifestUrl.Substring(0, manifestUrl.LastIndexOf('/') + 1) + name.Replace('\\', '/');
				fileName += ".deploy";
				fileUrl += ".deploy";
				taskXml += string.Format("<file FilePath=\"{0}\" FileName=\"{1}\" FileSize=\"{2}\" Url=\"{3}\"/>\r\n", filePath, fileName, size, fileUrl);
			}
			taskXml += "</files>\r\n";

			//
			Directory.CreateDirectory(task);

			Directory.CreateDirectory(task + "\\" + appPath);
			File.WriteAllBytes(task + "\\" + appPath + appName, appData);

			Directory.CreateDirectory(task + "\\" + manifestPath);
			File.WriteAllBytes(task + "\\" + manifestPath + manifestName, manifestData);

			File.WriteAllText(task + ".xml", taskXml);

			//
			Console.WriteLine(string.Format("CreateTask [{0}] Complete!", task));
		}