Esempio n. 1
0
        internal static void AddConfiguration(RejuicerConfigurationSource config)
        {
            try
            {
                _configurationLock.EnterWriteLock();

                if (_configurations.ContainsKey(config.RequestFor))
                {
                    throw new InvalidOperationException("There is already a configuration for this URL.");
                }

                Log.WriteLine("Creating configuration for request URL '{0}'", config.RequestFor);

                if (config.ContainsPlaceHolder)
                {
                    // Remember that there is a placeholder in one of the configurations.
                    _configurationContainsPlaceholder = true;
                }

                _configurations.Add(config.RequestFor, config);
            }
            finally
            {
                _configurationLock.ExitWriteLock();
            }

            // Generate the content so that it is cached.
            config.GetContent(cacheProvider);
        }
Esempio n. 2
0
 public DirectoryFileMatchConfigurer(ICompactorConfigurer compactorConfiguration, RejuicerConfigurationSource configuration, string directoryPath, Mode mode)
 {
     _compactorConfiguration = compactorConfiguration;
     _configuration          = configuration;
     _directoryPath          = directoryPath;
     _mode = mode;
 }
 public DirectoryFileMatchConfigurer(ICompactorConfigurer compactorConfiguration, RejuicerConfigurationSource configuration, string directoryPath, Mode mode)
 {
     _compactorConfiguration = compactorConfiguration;
     _configuration = configuration;
     _directoryPath = directoryPath;
     _mode = mode;
 }
Esempio n. 4
0
        internal static RejuicerConfigurationSource GetConfigFor(string requestedFilename)
        {
            try
            {
                _configurationLock.EnterReadLock();

                requestedFilename = MakeVirtualPathFromRequestUrl(requestedFilename);

                if (!_configurationContainsPlaceholder)
                {
                    // There are no placeholders in our configurations, so perform a quick dictionary lookup
                    RejuicerConfigurationSource model = null;

                    if (_configurations.TryGetValue(requestedFilename, out model))
                    {
                        return(model);
                    }

                    // No matching file configurations were found, so return nothing.
                    return(null);
                }

                // There are placeholders in the configuration, so iterate over each and look for a match
                // remove any placeholders from the incoming requested filenames
                var matchUrl = requestedFilename.Replace(RejuicerConfigurationSource.FilenameUniquePlaceholder,
                                                         "1234");

                foreach (var pair in _configurations)
                {
                    var regexp = pair.Value.RequestFor.Replace(RejuicerConfigurationSource.FilenameUniquePlaceholder, "[0-9]+");

                    if (Regex.IsMatch(matchUrl, regexp))
                    {
                        return(pair.Value);
                    }
                }

                return(null);
            }
            finally
            {
                _configurationLock.ExitReadLock();
            }
        }
 public CompactorConfigurer(RejuicerConfigurationSource config)
 {
     _config = config;
 }
Esempio n. 6
0
 public static ICompactorModeSelector ForJs(string requestedFilename)
 {
     var config = new RejuicerConfigurationSource(ResourceType.Js, requestedFilename);
     return new CompactorConfigurer(config);
 }
Esempio n. 7
0
 public static IEnumerable <string> VirtualPathsFor(RejuicerConfigurationSource config)
 {
     return(config == null?Enumerable.Empty <string>() : config.GetDependencies(config.ResourceType).Select(f => VirtualPathResolver.GetVirtualPathFor(f)));
 }
Esempio n. 8
0
        public static ICompactorModeSelector ForImage(string requestedFilename)
        {
            var config = new RejuicerConfigurationSource(ResourceType.Image, requestedFilename);

            return(new CompactorConfigurer(config));
        }
Esempio n. 9
0
 public CompactorConfigurer(RejuicerConfigurationSource config)
 {
     _config = config;
 }
Esempio n. 10
0
        internal static void AddConfiguration(RejuicerConfigurationSource config)
        {
            try
            {
                _configurationLock.EnterWriteLock();

                if (_configurations.ContainsKey(config.RequestFor))
                {
                    throw new InvalidOperationException("There is already a configuration for this URL.");
                }

                Log.WriteLine("Creating configuration for request URL '{0}'", config.RequestFor);

                if (config.ContainsPlaceHolder)
                {
                    // Remember that there is a placeholder in one of the configurations.
                    _configurationContainsPlaceholder = true;
                }

                _configurations.Add(config.RequestFor, config);
            }
            finally
            {
                _configurationLock.ExitWriteLock();
            }

            // Generate the content so that it is cached.
            config.GetContent(cacheProvider);
        }