Ejemplo n.º 1
0
        /// <summary>
        /// Convert compilation level enum value to code
        /// </summary>
        /// <param name="compilationLevel">Compilation level enum value</param>
        /// <returns>Compilation level code</returns>
        internal static string ConvertCompilationLevelEnumValueToCode(CompilationLevel compilationLevel)
        {
            string code;

            switch (compilationLevel)
            {
            case CompilationLevel.WhitespaceOnly:
                code = "WHITESPACE_ONLY";
                break;

            case CompilationLevel.Simple:
                code = "SIMPLE";
                break;

            case CompilationLevel.Advanced:
                code = "ADVANCED";
                break;

            default:
                throw new InvalidCastException(string.Format(CoreStrings.Common_EnumValueToCodeConversionFailed,
                                                             compilationLevel.ToString(), typeof(CompilationLevel)));
            }

            return(code);
        }
Ejemplo n.º 2
0
        public string Compress(string Input, CompilationLevel CompilationLevel)
        {
            WebClient oClient = new WebClient( );

            oClient.Headers.Add("content-type", "application/x-www-form-urlencoded");

            string szPostData = string.Format(_PostData, HttpUtility.UrlEncode(Input), Enum.GetName(typeof(CompilationLevel), CompilationLevel));
            string szResult   = oClient.UploadString(_ApiEndpoint, szPostData);

            return(szResult);
        }
Ejemplo n.º 3
0
 public ClosureCodeRequest(string apiUrl, CompilationLevel level, string jsContent)
 {
     apiUrl = string.IsNullOrEmpty(apiUrl) ? DefaultApiUrl : apiUrl;
     request = new Request(apiUrl,
         new List<KeyValuePair<string, string>>
             {
                      new KeyValuePair<string, string>("compilation_level", level.ToString()),
                      new KeyValuePair<string, string>("js_code", jsContent),
                      new KeyValuePair<string, string>("output_format", "xml"),
                      new KeyValuePair<string, string>("output_info", "compiled_code"),
                 });
 }
Ejemplo n.º 4
0
 public ClosureCodeRequest(string apiUrl, CompilationLevel level, string jsContent)
 {
     apiUrl  = string.IsNullOrEmpty(apiUrl) ? DefaultApiUrl : apiUrl;
     request = new Request(apiUrl,
                           new List <KeyValuePair <string, string> >
     {
         new KeyValuePair <string, string>("compilation_level", level.ToString()),
         new KeyValuePair <string, string>("js_code", jsContent),
         new KeyValuePair <string, string>("output_format", "xml"),
         new KeyValuePair <string, string>("output_info", "compiled_code"),
     });
 }
		/// <summary>
		/// Converts a compilation level enum value to code
		/// </summary>
		/// <param name="compilationLevel">Compilation level enum value</param>
		/// <returns>Compilation level code</returns>
		internal static string ConvertCompilationLevelEnumValueToCode(CompilationLevel compilationLevel)
		{
			string code;

			switch (compilationLevel)
			{
				case CompilationLevel.WhitespaceOnly:
					code = "WHITESPACE_ONLY";
					break;
				case CompilationLevel.Simple:
					code = "SIMPLE_OPTIMIZATIONS";
					break;
				case CompilationLevel.Advanced:
					code = "ADVANCED_OPTIMIZATIONS";
					break;
				default:
					throw new InvalidCastException(string.Format(CoreStrings.Common_EnumValueToCodeConversionFailed,
						compilationLevel.ToString(), typeof(CompilationLevel)));
			}

			return code;
		}