public static bool TryInitialize(ITracer tracer, PhysicalFileSystem fileSystem, string dotGVFSPath, out string error) { string dictionaryPath = Path.Combine(dotGVFSPath, GVFSConstants.DotGVFS.Databases.RepoMetadata); if (Instance != null) { if (!Instance.repoMetadata.DataFilePath.Equals(dictionaryPath, GVFSPlatform.Instance.Constants.PathComparison)) { throw new InvalidOperationException( string.Format( "TryInitialize should never be called twice with different parameters. Expected: '{0}' Actual: '{1}'", Instance.repoMetadata.DataFilePath, dictionaryPath)); } } else { Instance = new RepoMetadata(tracer); if (!FileBasedDictionary <string, string> .TryCreate( tracer, dictionaryPath, fileSystem, out Instance.repoMetadata, out error)) { return(false); } } error = null; return(true); }
private bool TryOpenMappingFile(ITracer tracer, string localCacheRoot, out FileBasedDictionary <string, string> mappingFile, out string errorMessage) { mappingFile = null; errorMessage = string.Empty; string error; string mappingFilePath = Path.Combine(localCacheRoot, MappingFile); if (!FileBasedDictionary <string, string> .TryCreate( tracer, mappingFilePath, this.fileSystem, out mappingFile, out error)) { errorMessage = "Could not open mapping file for local cache: " + error; EventMetadata metadata = CreateEventMetadata(); metadata.Add("mappingFilePath", mappingFilePath); metadata.Add("error", error); tracer.RelatedError(metadata, "TryOpenMappingFile: Could not open mapping file for local cache"); return(false); } return(true); }
private bool TryLoadSettings(out string error) { if (this.allSettings == null) { FileBasedDictionary <string, string> config = null; if (FileBasedDictionary <string, string> .TryCreate( tracer: null, dictionaryPath: this.configFile, fileSystem: this.fileSystem, output: out config, error: out error, keyComparer: StringComparer.OrdinalIgnoreCase)) { this.allSettings = config; return(true); } return(false); } error = null; return(true); }