Beispiel #1
0
        public static ICacheController <Tag> Create(CacheGeometry cacheGeometry
                                                    , IStorage <Tag> storage
                                                    , IReplacementStrategy <Tag> replacementStrategy)
        {
            ICacheController <Tag> cacheController = Create(cacheGeometry, storage);

            cacheController.ReplacementStrategy = replacementStrategy;
            return(cacheController);
        }
        public void AssertFileLastWriteTimeDifference(IReplacementStrategy replacementStrategy, Action<DateTime, DateTime> assert)
        {
            var replacer = new FileContentReplacer(replacementStrategy);

            var temporaryFilePath = Path.GetTempFileName();
            File.WriteAllText(temporaryFilePath, "dummy line");
            using (var temporaryFile = new TemporaryFile(temporaryFilePath))
            {
                var originalWriteTime = File.GetLastWriteTimeUtc(temporaryFile.AbsolutePath);

                Thread.Sleep(100); // delay to ensure we pick up any time difference

                replacer.Replace(temporaryFile.AbsolutePath);

                assert(originalWriteTime, File.GetLastWriteTimeUtc(temporaryFile.AbsolutePath));
            }
        }
Beispiel #3
0
        public string Replace(OptionPartTypes optionType, string optionPart)
        {
            IReplacementStrategy replacementStrategy = replacementFactory.GetReplacementFactoryStrategy(optionType);

            return(replacementStrategy.ReplaceOption(optionPart));
        }
        private void DeleteReferences(string projectDirectory, string deletedFileFullPath)
        {
            var replacementStrategies = new IReplacementStrategy[] {
                new ApplicationRelativeDeletionStrategy(projectDirectory, deletedFileFullPath),
                new FileRelativeDeletionStrategy(deletedFileFullPath)
            };

            UpdateFiles(projectDirectory, replacementStrategies);
        }
        private void UpdateFiles(string projectDirectory, IReplacementStrategy[] replacementStrategies)
        {
            try
            {
                var streamReplacer = new FileContentReplacer(replacementStrategies);

                var javascriptFiles = Directory.GetFiles(projectDirectory, "*.js", SearchOption.AllDirectories);

                SaveOpenJavaScriptFiles();

                //Parallel.ForEach(jsFiles, streamReplacer.Replace);
                foreach (var javascriptFile in javascriptFiles)
                {
                    streamReplacer.Replace(javascriptFile);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void MoveReferences(string projectDirectory, string oldFilePath, string newFilePath)
        {
            var replacementStrategies = new IReplacementStrategy[] {
                new ApplicationRelativeReplacementStrategy(projectDirectory, oldFilePath, newFilePath),
                new FileRelativeMatchingStrategy(oldFilePath, newFilePath)
            };

            UpdateFiles(projectDirectory, replacementStrategies);
        }