forked from PHOENIXCONTACT/MORYX-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIResourceGraph.cs
89 lines (75 loc) · 2.79 KB
/
IResourceGraph.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0
using System;
using System.Collections.Generic;
namespace Moryx.AbstractionLayer.Resources
{
/// <summary>
/// Component that holds the resource graph and maintains references to all nodes
/// </summary>
public interface IResourceGraph
{
/// <summary>
/// Get the resource with this id
/// </summary>
Resource Get(long id);
/// <summary>
/// Get only resources of this type
/// </summary>
TResource GetResource<TResource>()
where TResource : class, IResource;
/// <summary>
/// Get typed resource by id
/// </summary>
TResource GetResource<TResource>(long id)
where TResource : class, IResource;
/// <summary>
/// Get typed resource by name
/// </summary>
TResource GetResource<TResource>(string name)
where TResource : class, IResource;
/// <summary>
/// Get the only resource that matches the given predicate
/// </summary>
/// <returns>Instance if only one match was found, otherwise <value>null</value></returns>
TResource GetResource<TResource>(Func<TResource, bool> predicate)
where TResource : class, IResource;
/// <summary>
/// Get all resources of this type
/// </summary>
IEnumerable<TResource> GetResources<TResource>()
where TResource : class, IResource;
/// <summary>
/// Get all resources of this type that match the predicate
/// </summary>
IEnumerable<TResource> GetResources<TResource>(Func<TResource, bool> predicate)
where TResource : class, IResource;
/// <summary>
/// Create a new resource instance but DO NOT save it
/// </summary>
Resource Instantiate(string type);
/// <summary>
/// Instantiate a typed resource
/// </summary>
TResource Instantiate<TResource>()
where TResource : Resource;
/// <summary>
/// Instantiate a typed resource
/// </summary>
TResource Instantiate<TResource>(string type)
where TResource : class, IResource;
/// <summary>
/// Write changes on this object to the database
/// </summary>
void Save(IResource resource);
/// <summary>
/// Remove resource, but only flag it deleted
/// </summary>
bool Destroy(IResource resource);
/// <summary>
/// Remove a resource permanently and irreversible
/// </summary>
[Obsolete("Permanent removal of resources will be removed in the next major")]
bool Destroy(IResource resource, bool permanent);
}
}