public void Read(StreamReader r) { var current = new RepositoryState(); Guid otherRepoId; Guid? origin = null; string filename; DateTime mtime; string guidString = ReadString(r); RepositoryID = new Guid(guidString); Modified = new DateTime(long.Parse(ReadString(r)), DateTimeKind.Utc); while (!r.EndOfStream) { otherRepoId = new Guid(ReadString(r)); while (r.Peek() != 0) { filename = ReadString(r); // // Replace forward-slashes with the system directory separator character. // if (Path.DirectorySeparatorChar != '/') { filename = filename.Replace('/', Path.DirectorySeparatorChar); } if (otherRepoId == RepositoryID) { origin = new Guid(ReadString(r)); } mtime = DateTime.FromFileTimeUtc(long.Parse(ReadString(r))); current.MTimes.Add(filename, mtime); if (origin.HasValue) { Origin.Add(filename, origin.Value); origin = null; } } current.ID = otherRepoId; Repositories.Add(otherRepoId, current); current = new RepositoryState(); r.Read(); } Dirty = false; }
public void AddRepository(FooTree tree, Guid ID) { if (tree == null) throw new ArgumentNullException("tree"); if (ID == null) throw new ArgumentException("ID"); Dirty = true; Modified = DateTime.Now; RepositoryState repository = new RepositoryState(); repository.ID = ID; foreach (var file in tree.Files) { string filename = file.Key; repository.MTimes.Add(filename, file.Value.MTime); if (ID == RepositoryID) { Origin.Add(filename, RepositoryID); } } Repositories.Add(ID, repository); }