about summary refs log tree commit diff
path: root/LibMatrix/Interfaces/Services/IStorageProvider.cs
blob: fb7bb6dcd0a5ea5e06a29565612c35f4ea16c491 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
namespace LibMatrix.Interfaces.Services;

public interface IStorageProvider {
    // save all children of a type with reflection
    public Task SaveAllChildrenAsync<T>(string key, T value) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement SaveAllChildren<T>(key, value)!");
        throw new NotImplementedException();
    }

    // load all children of a type with reflection
    public Task<T?> LoadAllChildrenAsync<T>(string key) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement LoadAllChildren<T>(key)!");
        throw new NotImplementedException();
    }

    public Task SaveObjectAsync<T>(string key, T value) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement SaveObject<T>(key, value)!");
        throw new NotImplementedException();
    }

    // load
    public Task<T?> LoadObjectAsync<T>(string key) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement LoadObject<T>(key)!");
        throw new NotImplementedException();
    }

    // check if exists
    public Task<bool> ObjectExistsAsync(string key) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement ObjectExists(key)!");
        throw new NotImplementedException();
    }

    // get all keys
    public Task<IEnumerable<string>> GetAllKeysAsync() {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement GetAllKeys()!");
        throw new NotImplementedException();
    }

    // delete
    public Task DeleteObjectAsync(string key) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement DeleteObject(key)!");
        throw new NotImplementedException();
    }

    // save stream
    public Task SaveStreamAsync(string key, Stream stream) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement SaveStream(key, stream)!");
        throw new NotImplementedException();
    }

    // load stream
    public Task<Stream?> LoadStreamAsync(string key) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement LoadStream(key)!");
        throw new NotImplementedException();
    }

    // copy
    public async Task CopyObjectAsync(string sourceKey, string destKey) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement CopyObject(sourceKey, destKey), using load + save!");
        var data = await LoadObjectAsync<object>(sourceKey);
        await SaveObjectAsync(destKey, data);
    }

    // move
    public async Task MoveObjectAsync(string sourceKey, string destKey) {
        Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement MoveObject(sourceKey, destKey), using copy + delete!");
        await CopyObjectAsync(sourceKey, destKey);
        await DeleteObjectAsync(sourceKey);
    }
}