public Stream Get(StorageIdentity identity) { var path = GetPath(identity); if (!File.Exists(path)) throw new FileNotFoundException(); return File.OpenRead(path); }
public void Delete(StorageIdentity identity) { var path = GetPath(identity); if (!File.Exists(path)) throw new FileNotFoundException(); File.Delete(path); }
public IEnumerable<StorageIdentity> List(StorageIdentity identity) { return Directory .EnumerateFiles(GetDirectory(identity)) .Select(file => new StorageIdentity { Id = Path.GetFileNameWithoutExtension(file), Name = identity.Name, Type = identity.Type }); }
public void Save(StorageIdentity identity, MemoryStream stream) { if (!Directory.Exists(GetDirectory(identity))) Directory.CreateDirectory(GetDirectory(identity)); var path = GetPath(identity); if (File.Exists(path)) File.Delete(path); using (var fs = File.OpenWrite(path)) { stream.WriteTo(fs); } }
internal static IEnumerable<object> List(StorageIdentity identity, Settings settings) { return settings.Endpoint .List(identity) .Select(x => DeserializeObject(x.Id, identity.IdType, settings)); }
internal static IEnumerable <object> List(StorageIdentity identity, Settings settings) { return(settings.Endpoint .List(identity) .Select(x => DeserializeObject(x.Id, identity.IdType, settings))); }
private string GetPath(StorageIdentity identity) { return GetDirectory(identity) + GetFilename(identity); }
private string GetFilename(StorageIdentity identity) { return identity.Id + "." + fileEnding; }
private string GetDirectory(StorageIdentity identity) { return savePath + identity.Name + Path.DirectorySeparatorChar; }