protected override PathAccess FetchPathAccess(string pathName) { // Read it from the file system. string f = Path.Combine(basePath, pathName); // If it doesn't exist, generate an error if (!File.Exists(f)) throw new ApplicationException("Path '" + pathName + "' not found input this root service."); // If it does exist, does the .deleted file exist indicating this root // path was removed, if (File.Exists(Path.Combine(basePath, pathName + ".deleted"))) throw new ApplicationException("Path '" + pathName + "' did exist but was deleted."); // Read the summary data for this path. string summaryFile = Path.Combine(basePath, pathName + ".summary"); Util.Properties p = new Util.Properties(); using (FileStream fileStream = new FileStream(summaryFile, FileMode.Open, FileAccess.Read)) { p.Load(fileStream); } string pathType = p.GetProperty("path_type"); // Format it into a PathAccess object, FileStream accessStream = new FileStream(f, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 1024, FileOptions.WriteThrough); return new PathAccess(accessStream, pathName, pathType); }
public void Load(ConfigSource config, Stream input) { if (!input.CanRead) throw new ArgumentException("Cannot read from the stream.", "input"); Util.Properties properties = new Util.Properties(); properties.Load(input); foreach(KeyValuePair<object, object> pair in properties) { config.SetValue((string)pair.Key, (string)pair.Value); } }
protected override void OnStart() { try { // Read the manager service address from the properties file, Util.Properties p = new Util.Properties(); // Contains the root properties, string propFile = Path.Combine(basePath, "00.properties"); if (File.Exists(propFile)) { using (FileStream fin = new FileStream(propFile, FileMode.Open, FileAccess.Read)) { p.Load(fin); } } // Fetch the manager service property, string v = p.GetProperty("manager_address"); if (v != null) { ManagerAddress = ServiceAddresses.ParseString(v); } } catch (IOException e) { throw new ApplicationException("IO Error: " + e.Message); } }