Пример #1
0
        /// <summary>
        /// Initializes CSS autoprefixer
        /// </summary>
        private void Initialize()
        {
            if (_initializedFlag.Set())
            {
                _jsEngine.EmbedHostObject(COUNTRY_STATISTICS_SERVICE_VARIABLE_NAME, CountryStatisticsService.Instance);

                Assembly assembly = GetType().Assembly;

                _jsEngine.ExecuteResource(ResourceHelpers.GetResourceName(AUTOPREFIXER_LIBRARY_FILE_NAME), assembly);
                _jsEngine.ExecuteResource(ResourceHelpers.GetResourceName(AUTOPREFIXER_HELPER_FILE_NAME), assembly);
            }
        }
        /// <summary>
        /// Gets a statistics for country
        /// </summary>
        /// <param name="countryCode">Two-letter country code</param>
        /// <returns>Statistics for country</returns>
        public string GetStatisticsForCountry(string countryCode)
        {
            string statistics;
            string resourceName = ResourceHelpers.GetResourceName(
                AUTOPREFIXER_COUNTRY_STATISTICS_DIRECTORY_NAME + "." + countryCode + ".js");

            try
            {
                statistics = Utils.GetResourceAsString(resourceName, GetType().Assembly);
            }
            catch (NullReferenceException)
            {
                throw new CssAutoprefixingException(
                          string.Format(Strings.PostProcessors_CountryStatisticsNotFound, countryCode));
            }

            return(statistics);
        }