3 using System.Collections.Generic;
7 // Define a storage mechanism for a help source
8 public interface IDocStorage : IDisposable
10 // Tell if the storage can store successive change to the doc as revision
11 bool SupportRevision { get; }
12 IDocRevisionManager RevisionManager { get; }
14 // Tell if the storage support modifying an existing data
15 bool SupportChange { get; }
17 /* Store data inside the storage backend
18 * if SupportChange is false and user try to store something with an existing id
19 * an exception will be thrown
20 * if id is null or empty, the storage will try to create an automatic id. In all
21 * case the id that has been used to store the content is returned by the method
23 string Store (string id, string text);
24 string Store (string id, byte[] data);
25 string Store (string id, Stream stream);
27 Stream Retrieve (string id);
29 IEnumerable<string> GetAvailableIds ();
32 public interface IDocRevisionManager
34 Stream RetrieveWithRevision (string id, string revision);
36 // This should be ordered by most recent first
37 IEnumerable<string> AvailableRevisionsForId (string id);
38 // This can simply be implemented with above property but it can also be
39 // a revision storage symbolic value like "HEAD"
40 string LatestRevisionForId (string id);
42 // A commit message for instance
43 string GetRevisionDescription (string revision);
46 public static class DocRevisionManagerExtensions
48 public static Stream RetrieveLatestRevision (this IDocRevisionManager revManager, string id)
50 return revManager.RetrieveWithRevision (id, revManager.LatestRevisionForId (id));