public AssemblyInfoFileUpdate(Arguments args, string workingDirectory, VersionVariables variables, IFileSystem fileSystem)
        {
            if (!args.UpdateAssemblyInfo) return;

            if (args.Output != OutputType.Json)
                Console.WriteLine("Updating assembly info files");

            var assemblyInfoFiles = GetAssemblyInfoFiles(workingDirectory, args, fileSystem);

            foreach (var assemblyInfoFile in assemblyInfoFiles)
            {
                var backupAssemblyInfo = assemblyInfoFile + ".bak";
                var localAssemblyInfo = assemblyInfoFile;
                fileSystem.Copy(assemblyInfoFile, backupAssemblyInfo, true);
                restoreBackupTasks.Add(() =>
                {
                    if (fileSystem.Exists(localAssemblyInfo))
                        fileSystem.Delete(localAssemblyInfo);
                    fileSystem.Move(backupAssemblyInfo, localAssemblyInfo);
                });
                cleanupBackupTasks.Add(() => fileSystem.Delete(backupAssemblyInfo));

                var assemblyVersion = variables.AssemblySemVer;
                var assemblyInfoVersion = variables.InformationalVersion;
                var assemblyFileVersion = variables.MajorMinorPatch + ".0";
                var fileContents = fileSystem.ReadAllText(assemblyInfoFile)
                    .RegexReplace(@"AssemblyVersion\(""\d+.\d+.\d+(.(\d+|\*))?""\)", string.Format("AssemblyVersion(\"{0}\")", assemblyVersion))
                    .RegexReplace(@"AssemblyInformationalVersion\(""\d+.\d+.\d+(.(\d+|\*))?""\)", string.Format("AssemblyInformationalVersion(\"{0}\")", assemblyInfoVersion))
                    .RegexReplace(@"AssemblyFileVersion\(""\d+.\d+.\d+(.(\d+|\*))?""\)", string.Format("AssemblyFileVersion(\"{0}\")", assemblyFileVersion));

                fileSystem.WriteAllText(assemblyInfoFile, fileContents);
            }
        }
        public static Config Provide(string gitDirectory, IFileSystem fileSystem)
        {
            var configFilePath = GetConfigFilePath(gitDirectory);

            if (fileSystem.Exists(configFilePath))
            {
                var readAllText = fileSystem.ReadAllText(configFilePath);
                LegacyConfigNotifier.Notify(new StringReader(readAllText));

                return ConfigSerialiser.Read(new StringReader(readAllText));
            }

            return new Config();
        }
        public AssemblyInfoFileUpdate(Arguments args, string workingDirectory, VersionVariables variables, IFileSystem fileSystem)
        {
            if (!args.UpdateAssemblyInfo) return;

            if (args.Output != OutputType.Json)
                Logger.WriteInfo("Updating assembly info files");

            var assemblyInfoFiles = GetAssemblyInfoFiles(workingDirectory, args, fileSystem).ToList();
            Logger.WriteInfo(string.Format("Found {0} files", assemblyInfoFiles.Count));

            var assemblyVersion = variables.AssemblySemVer;
            var assemblyVersionRegex = new Regex(@"AssemblyVersion\s*\(\s*""[^""]*""\s*\)");
            var assemblyVersionString = !string.IsNullOrWhiteSpace(assemblyVersion) ? string.Format("AssemblyVersion(\"{0}\")", assemblyVersion) : null;
            var assemblyInfoVersion = variables.InformationalVersion;
            var assemblyInfoVersionRegex = new Regex(@"AssemblyInformationalVersion\s*\(\s*""[^""]*""\s*\)");
            var assemblyInfoVersionString = string.Format("AssemblyInformationalVersion(\"{0}\")", assemblyInfoVersion);
            var assemblyFileVersion = variables.MajorMinorPatch + ".0";
            var assemblyFileVersionRegex = new Regex(@"AssemblyFileVersion\s*\(\s*""[^""]*""\s*\)");
            var assemblyFileVersionString = string.Format("AssemblyFileVersion(\"{0}\")", assemblyFileVersion);

            foreach (var assemblyInfoFile in assemblyInfoFiles)
            {
                var backupAssemblyInfo = assemblyInfoFile.FullName + ".bak";
                var localAssemblyInfo = assemblyInfoFile.FullName;
                fileSystem.Copy(assemblyInfoFile.FullName, backupAssemblyInfo, true);
                restoreBackupTasks.Add(() =>
                {
                    if (fileSystem.Exists(localAssemblyInfo))
                        fileSystem.Delete(localAssemblyInfo);
                    fileSystem.Move(backupAssemblyInfo, localAssemblyInfo);
                });
                cleanupBackupTasks.Add(() => fileSystem.Delete(backupAssemblyInfo));

                var fileContents = fileSystem.ReadAllText(assemblyInfoFile.FullName);
                var appendedAttributes = false;
                if (!string.IsNullOrWhiteSpace(assemblyVersion))
                {
                    fileContents = ReplaceOrAppend(assemblyVersionRegex, fileContents, assemblyVersionString, assemblyInfoFile.Extension, ref appendedAttributes);
                }
                fileContents = ReplaceOrAppend(assemblyInfoVersionRegex, fileContents, assemblyInfoVersionString, assemblyInfoFile.Extension, ref appendedAttributes);
                fileContents = ReplaceOrAppend(assemblyFileVersionRegex, fileContents, assemblyFileVersionString, assemblyInfoFile.Extension, ref appendedAttributes);

                if (appendedAttributes)
                {
                    // If we appended any attributes, put a new line after them
                    fileContents += Environment.NewLine;
                }
                fileSystem.WriteAllText(assemblyInfoFile.FullName, fileContents);
            }
        }
        // Internal for unit tests.
        internal void AddConnectionString(string connectionStringName, string dataBaseName)
        {
            var     appSettingsFile = Path.Combine(_applicationInfo.ApplicationBasePath, "appsettings.json");
            JObject content;
            bool    writeContent = false;

            if (!_fileSystem.FileExists(appSettingsFile))
            {
                content      = new JObject();
                writeContent = true;
            }
            else
            {
                content = JObject.Parse(_fileSystem.ReadAllText(appSettingsFile));
            }

            string dataNodeName             = "Data";
            string connectionStringNodeName = "ConnectionString";

            if (content[dataNodeName] == null)
            {
                writeContent          = true;
                content[dataNodeName] = new JObject();
            }

            if (content[dataNodeName][connectionStringName] == null)
            {
                writeContent = true;
                content[dataNodeName][connectionStringName] = new JObject();
            }

            if (content[dataNodeName][connectionStringName][connectionStringNodeName] == null)
            {
                writeContent = true;
                content[dataNodeName][connectionStringName][connectionStringNodeName] =
                    string.Format("Server=(localdb)\\mssqllocaldb;Database={0};Trusted_Connection=True;MultipleActiveResultSets=true",
                                  dataBaseName);
            }

            // Json.Net loses comments so the above code if requires any changes loses
            // comments in the file. The writeContent bool is for saving
            // a specific case without losing comments - when no changes are needed.
            if (writeContent)
            {
                _fileSystem.WriteAllText(appSettingsFile, content.ToString());
            }
        }
Example #5
0
        public ITemplate FindTemplate(string templateId)
        {
            var templateContentPath = "";

            foreach (var path in _searchPaths)
            {
                var candidatePath = Path.Combine(path, templateId);
                if (Directory.Exists(candidatePath) &&
                    File.Exists(Path.Combine(candidatePath, TemplateConfigFileName)))
                {
                    templateContentPath = candidatePath;
                    break;
                }
            }

            if (string.IsNullOrEmpty(templateContentPath))
            {
                var msg = string.Format(MessageStrings.TemplateNotFoundError, templateId);
                _logger.Log(msg, LogMessageLevel.Trace);
                _logger.Log($"Search paths: {string.Join(Environment.NewLine, _searchPaths)}", LogMessageLevel.Trace);
                throw new InvalidOperationException(msg);
            }


            var templateConfigTxt = _fileSystem.ReadAllText(Path.Combine(templateContentPath, TemplateConfigFileName));
            var templateConfig    = JsonConvert.DeserializeObject <ITemplate>(templateConfigTxt);

            if (templateConfig.CopyOnlySources != null)
            {
                for (int i = 0; i < templateConfig.CopyOnlySources.Length; i++)
                {
                    templateConfig.CopyOnlySources[i] = Path.Combine(templateContentPath, templateConfig.CopyOnlySources[i]);
                }
            }


            if (templateConfig.TemplateSources != null)
            {
                for (int i = 0; i < templateConfig.TemplateSources.Length; i++)
                {
                    templateConfig.TemplateSources[i] = Path.Combine(templateContentPath, templateConfig.TemplateSources[i]);
                }
            }

            return(templateConfig);
        }
Example #6
0
        private bool IsLockedInternal(string path)
        {
            if (_root.FileExists(path))
            {
                var content = _root.ReadAllText(path);

                if (DateTime.TryParse(content, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out var creationUtc))
                {
                    // if expired the file is not removed
                    // it should be automatically as there is a finalizer in LockFile
                    // or the next taker can do it, unless it also fails, again
                    return(creationUtc.ToUniversalTime().Add(Expiration) > DateTime.UtcNow);
                }
            }

            return(false);
        }
Example #7
0
        private static List <ExpandoObject> GetKataFiles(IFileSystem fileSystem, string[] files)
        {
            var kataFiles = new List <ExpandoObject>();

            foreach (var file in files)
            {
                if (file.Contains("AssemblyInfo") || file.Contains("\\bin\\") || file.Contains("\\obj\\"))
                {
                    continue;
                }
                dynamic item = new ExpandoObject();
                item.Name     = new FileInfo(file).Name;
                item.Contents = fileSystem.ReadAllText(file);
                kataFiles.Add(item);
            }
            return(kataFiles);
        }
        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);

            DockControl dock = this.FindControl <DockControl>("DockControl");

            SerializedDock?serializedDock = null;

            if (fileSystem.Exists(DockSettingsFile))
            {
                try
                {
                    serializedDock = JsonConvert.DeserializeObject <SerializedDock>(fileSystem.ReadAllText(DockSettingsFile));
                } catch {}
            }

            dock.Layout = avaloniaDockAdapter.Initialize(serializedDock);
        }
Example #9
0
        public bool Load(string fileName)
        {
            string json;
            var    found = _fs.ReadAllText(fileName, out json);

            if (!found)
            {
                return(false);
            }

            var tmp = JsonConvert.DeserializeObject <XenProjectFile>(json);

            Schema     = tmp.Schema;
            Assemblies = tmp.Assemblies;
            Views      = tmp.Views;

            return(true);
        }
        public static Config Provide(string gitDirectory, IFileSystem fileSystem)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            var configFilePath = GetConfigFilePath(gitDirectory);

            if (fileSystem.Exists(configFilePath))
            {
                var readAllText = fileSystem.ReadAllText(configFilePath);

                return ConfigSerializer.Read(new StringReader(readAllText));
            }

            return new Config();
        }
Example #11
0
 void CopyAndReplaceVariables(AbsoluteFilePath src, AbsoluteFilePath dst)
 {
     using (var backup = _fileSystem.BackupAndDeleteFile(dst))
     {
         try
         {
             var templateDocument = _fileSystem.ReadAllText(src, 5);
             var newDocument      = _templateParser.PreprocessIncludeRegions(templateDocument);
             newDocument = _templateParser.ReplaceVariables(newDocument);
             _fileSystem.WriteNewText(dst, newDocument);
         }
         catch (Exception)
         {
             backup.Restore();
             throw;
         }
     }
 }
Example #12
0
        public FileContentResult ReadFileContent(string path)
        {
            FileContentResult result = new FileContentResult {
                IsContentRead = true
            };

            try
            {
                result.Content = _fileSystem.ReadAllText(path);
                result.Name    = _fileSystem.GetFileNameWithoutExtension(path);
            }
            catch (Exception)
            {
                result.IsContentRead = false;
            }

            return(result);
        }
Example #13
0
        /// <summary>
        /// Gets the GUID.
        /// </summary>
        /// <returns>The GUID.</returns>
        /// <param name="type">Type.</param>
        public string GetGuid(Type type)
        {
            var metaFile = m_fs.GetFiles("{0}.cs.meta".With(type.Name)).FirstOrDefault();

            if (metaFile == null)
            {
                var assemblyName = m_fs.GetFileNameWithoutExtension(type.Assembly.CodeBase);
                metaFile = m_fs.GetFiles("{0}.dll.meta".With(assemblyName)).FirstOrDefault();

                if (metaFile == null)
                {
                    throw new InvalidOperationException("Could not find .meta file of type '{0}'.".With(type.Name));
                }
            }

            var content = m_fs.ReadAllText(metaFile);

            return(s_guidRegex.Match(content).Groups[1].Value);
        }
        public static Config Provide(string gitDirectory, IFileSystem fileSystem)
        {
            var configFilePath = GetConfigFilePath(gitDirectory);

            if (fileSystem.Exists(configFilePath))
            {
                var readAllText = fileSystem.ReadAllText(configFilePath);
                if (oldAssemblyVersioningScheme.IsMatch(readAllText))
                {
                    readAllText = oldAssemblyVersioningScheme.Replace(readAllText, "assembly-versioning-scheme");
                    fileSystem.WriteAllText(configFilePath, readAllText);
                    Logger.WriteWarning("Found legacy configuration value 'assemblyVersioningScheme', replaced with 'assembly-versioning-scheme");
                }

                return(ConfigReader.Read(new StringReader(readAllText)));
            }

            return(new Config());
        }
Example #15
0
        public string GetCachedFileContent(long repositoryId, string repositoryName, string filePath, string sha, Func <long, string, string> loadContent)
        {
            string cacheKey = CreateCacheKey(filePath, sha);

            string cachedFilePath = $"{LocalCacheFolder}\\{repositoryName}\\{cacheKey}.cache";

            if (fileSystem.FileExists(cachedFilePath))
            {
                return(fileSystem.ReadAllText(cachedFilePath));
            }

            string actualContent = loadContent(repositoryId, filePath);

            ClearCacheFor(repositoryName, filePath);

            StoreInCache(cachedFilePath, actualContent);

            return(actualContent);
        }
        public void UpdatesVersionInAssemblyInfoFile()
        {
            _context.Arguments.UpdateAssemblyInfo = true;
            const string assemblyInfoFile = "C:\\Dir\\Properties\\AssemblyInfo.cs";

            _fileSystem
            .GetFiles(Arg.Any <string>(), Arg.Any <string>(), SearchOption.AllDirectories)
            .Returns(new[] { assemblyInfoFile });
            _fileSystem.ReadAllText(assemblyInfoFile).Returns(ExampleAssemblyInfoFile);

            using (new AssemblyInfoUpdate(_fileSystem, _context)) { }

            var expected = ExampleAssemblyInfoFile
                           .Replace("AssemblyVersion(\"1.0.0.0\")", "AssemblyVersion(\"1.2.0.0\")")
                           .Replace("AssemblyInformationalVersion(\"1.0.0.0\")", "AssemblyInformationalVersion(\"1.2.3-beta+004\")")
                           .Replace("AssemblyFileVersion(\"1.0.0.0\")", "AssemblyFileVersion(\"1.2.3.4\")");

            _fileSystem.Received().WriteAllText(assemblyInfoFile, expected);
        }
        public string ReadCachedModule(string filePath)
        {
            if (_skipCache)
            {
                return(string.Empty);
            }

            var path = GetCacheFilePath(filePath);

            if (string.IsNullOrEmpty(path))
            {
                return(string.Empty);
            }

            var fileIsOkay = false;

            try {
                var cacheTime  = _fs.GetLastWriteTimeUtc(path);
                var sourceTime = _fs.GetLastWriteTimeUtc(filePath);
                if (sourceTime <= cacheTime)
                {
                    var assemblyTime = _fs.GetLastWriteTimeUtc(GetType().Assembly.Location);
                    if (assemblyTime <= cacheTime)
                    {
                        fileIsOkay = true;
                    }
                }
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
            }

            if (fileIsOkay)
            {
                try {
                    return(_fs.ReadAllText(filePath));
                } catch (IOException) { } catch (UnauthorizedAccessException) { }
            }

            _log?.Log(TraceEventType.Verbose, "Invalidate cached module", path);
            _fs.DeleteFileWithRetries(path);
            return(string.Empty);
        }
        public static IEnumerable <Package> SearchForPackagesIn(IFileSystem fs, AbsoluteDirectoryPath searchPath)
        {
            var files = fs.GetFiles(searchPath);
            var sourcePropertyFile = files.FirstOrNone(f => f.Name == new FileName("source.properties"));

            if (sourcePropertyFile.HasValue)
            {
                var package = TryParse(fs.ReadAllText(sourcePropertyFile.Value, 5));
                if (package.HasValue)
                {
                    yield return(package.Value);
                }
            }

            foreach (var package in fs.GetDirectories(searchPath)
                     .SelectMany(dir => SearchForPackagesIn(fs, dir)))
            {
                yield return(package);
            }
        }
Example #19
0
        private bool TryGetPrivateKey(string keyDir, string publicKey, out string privateKey)
        {
            try
            {
                var publicKeyPath = Path.Combine(keyDir, publicKey);

                // 64 hex characters, 32-bits... 100 is just a sanity check in case it has a byte order mark something else nuts
                if (_fileSystem.FileExists(publicKeyPath) && _fileSystem.GetFileLength(publicKeyPath) < 100)
                {
                    privateKey = _fileSystem.ReadAllText(publicKeyPath);
                    return(!string.IsNullOrWhiteSpace(privateKey));
                }
            }
            catch
            {
            }

            privateKey = null;
            return(false);
        }
        public AssemblyInfoFileUpdate(Arguments args, string workingDirectory, VersionVariables variables, IFileSystem fileSystem)
        {
            if (!args.UpdateAssemblyInfo) return;

            if (args.Output != OutputType.Json)
                Logger.WriteInfo("Updating assembly info files");

            var assemblyInfoFiles = GetAssemblyInfoFiles(workingDirectory, args, fileSystem);
            Logger.WriteInfo(string.Format("Found {0} files", assemblyInfoFiles.Count()));

            var assemblyVersion = variables.AssemblySemVer;
            var assemblyVersionRegex = new Regex(@"AssemblyVersion\(""[^""]*""\)");
            var assemblyVersionString = string.Format("AssemblyVersion(\"{0}\")", assemblyVersion);
            var assemblyInfoVersion = variables.InformationalVersion;
            var assemblyInfoVersionRegex = new Regex(@"AssemblyInformationalVersion\(""[^""]*""\)");
            var assemblyInfoVersionString = string.Format("AssemblyInformationalVersion(\"{0}\")", assemblyInfoVersion);
            var assemblyFileVersion = variables.MajorMinorPatch + ".0";
            var assemblyFileVersionRegex = new Regex(@"AssemblyFileVersion\(""[^""]*""\)");
            var assemblyFileVersionString = string.Format("AssemblyFileVersion(\"{0}\")", assemblyFileVersion);

            foreach (var assemblyInfoFile in assemblyInfoFiles.Select(f => new FileInfo(f)))
            {
                var backupAssemblyInfo = assemblyInfoFile.FullName + ".bak";
                var localAssemblyInfo = assemblyInfoFile.FullName;
                fileSystem.Copy(assemblyInfoFile.FullName, backupAssemblyInfo, true);
                restoreBackupTasks.Add(() =>
                {
                    if (fileSystem.Exists(localAssemblyInfo))
                        fileSystem.Delete(localAssemblyInfo);
                    fileSystem.Move(backupAssemblyInfo, localAssemblyInfo);
                });
                cleanupBackupTasks.Add(() => fileSystem.Delete(backupAssemblyInfo));

                var fileContents = fileSystem.ReadAllText(assemblyInfoFile.FullName);
                fileContents = ReplaceOrAppend(assemblyVersionRegex, fileContents, assemblyVersionString);
                fileContents = ReplaceOrAppend(assemblyInfoVersionRegex, fileContents, assemblyInfoVersionString);
                fileContents = ReplaceOrAppend(assemblyFileVersionRegex, fileContents, assemblyFileVersionString);

                fileSystem.WriteAllText(assemblyInfoFile.FullName, fileContents);
            }
        }
Example #21
0
        bool ShouldClean(AbsoluteFilePath versionFile)
        {
            if (!_fs.Exists(versionFile))
            {
                return(true);
            }

            Version version;

            if (!Version.TryParse(_fs.ReadAllText(versionFile, 3), out version))
            {
                return(true);
            }

            if (version != _version)
            {
                return(true);
            }

            return(false);
        }
Example #22
0
        public async Task AddFileFromTemplateAsync(string outputPath, string templateName,
                                                   IEnumerable <string> templateFolders,
                                                   object templateModel)
        {
            if (templateFolders == null)
            {
                throw new ArgumentNullException(nameof(templateFolders));
            }

            ExceptionUtilities.ValidateStringArgument(outputPath, "outputPath");
            ExceptionUtilities.ValidateStringArgument(templateName, "templateName");

            var templatePath = _filesLocator.GetFilePath(templateName, templateFolders);

            if (string.IsNullOrEmpty(templatePath))
            {
                throw new InvalidOperationException(string.Format(
                                                        MessageStrings.TemplateFileNotFound,
                                                        templateName,
                                                        string.Join(";", templateFolders)));
            }

            Debug.Assert(_fileSystem.FileExists(templatePath));
            var templateContent = _fileSystem.ReadAllText(templatePath);

            var templateResult = await _templatingService.RunTemplateAsync(templateContent, templateModel);

            if (templateResult.ProcessingException != null)
            {
                throw new InvalidOperationException(string.Format(
                                                        MessageStrings.TemplateProcessingError,
                                                        templatePath,
                                                        templateResult.ProcessingException.Message));
            }

            using (var sourceStream = new MemoryStream(Encoding.UTF8.GetBytes(templateResult.GeneratedText)))
            {
                await AddFileHelper(outputPath, sourceStream);
            }
        }
        private static TemplateRenderingResult GetTemplateOutput(Project project, IFileSystem fileSystem, string template, string projectRelativeOutputPath, Hashtable model, bool force)
        {
            var templateFullPath = FindTemplateAssertExists(project, fileSystem, template);
            var templateContent = fileSystem.ReadAllText(templateFullPath);
            templateContent = PreprocessTemplateContent(templateContent);

            // Create the T4 host and engine
            using (var host = new DynamicTextTemplatingEngineHost { TemplateFile = templateFullPath }) {
                var t4Engine = GetT4Engine();

                // Make it possible to reference the same assemblies that your project references
                // using <@ Assembly @> directives.
                host.AddFindableAssembly(FindProjectAssemblyIfExists(project));
                foreach (dynamic reference in ((dynamic)project.Object).References) {
                    if ((!string.IsNullOrEmpty(reference.Path)) && (!reference.AutoReferenced))
                        host.AddFindableAssembly(reference.Path);
                }

                string projectRelativeOutputPathWithExtension = null;
                ProjectItem existingOutputProjectItem = null;
                if (!string.IsNullOrEmpty(projectRelativeOutputPath)) {
                    // Respect the <#@ Output Extension="..." #> directive
                    projectRelativeOutputPathWithExtension = projectRelativeOutputPath + GetOutputExtension(host, t4Engine, templateContent);

                    // Resolve the output path and ensure it doesn't already exist (unless "Force" is set)
                    var outputDiskPath = Path.Combine(project.GetFullPath(), projectRelativeOutputPathWithExtension);
                    existingOutputProjectItem = project.GetProjectItem(projectRelativeOutputPathWithExtension);
                    if (existingOutputProjectItem != null)
                        outputDiskPath = existingOutputProjectItem.GetFullPath();
                    if ((!force) && fileSystem.FileExists(outputDiskPath)) {
                        return new TemplateRenderingResult(projectRelativeOutputPathWithExtension) { SkipBecauseFileExists = true };
                    }
                }

                // Convert the incoming Hashtable to a dynamic object with properties for each of the Hashtable entries
                host.Model = DynamicViewModel.FromObject(model);

                // Run the text transformation
                var templateOutput = t4Engine.ProcessTemplate(templateContent, host);
                return new TemplateRenderingResult(projectRelativeOutputPathWithExtension) {
                    Content = templateOutput,
                    Errors = host.Errors,
                    ExistingProjectItemToOverwrite = existingOutputProjectItem,
                };
            }
        }
        private static string GetConfigFileHash(IFileSystem fileSystem, GitPreparer gitPreparer)
        {
            // will return the same hash even when config file will be moved
            // from workingDirectory to rootProjectDirectory. It's OK. Config essentially is the same.
            var configFilePath = ConfigurationProvider.SelectConfigFilePath(gitPreparer, fileSystem);
            if (!fileSystem.Exists(configFilePath))
            {
                return string.Empty;
            }

            var configFileContent = fileSystem.ReadAllText(configFilePath);
            return GetHash(configFileContent);
        }
Example #25
0
 public void Load(IFileSystem fs)
 {
     Text = fs.ReadAllText(FileName);
     Dirty = false;
 }
 public static bool IsFileEmpty(IFileSystem fileSystem, string fileName)
 {
     var fileContents = fileSystem.ReadAllText(fileName);
     return string.IsNullOrEmpty(fileContents);
 }