|
| 1 | +using System.Threading; |
| 2 | +using System.Threading.Tasks; |
| 3 | +using Xtensive.Orm; |
| 4 | +using Xtensive.Orm.Configuration; |
| 5 | + |
| 6 | +namespace Xtensive.Orm.Interfaces |
| 7 | +{ |
| 8 | + /// <summary> |
| 9 | + /// Defindes <see cref="StorageNode"/>-dependant operations. |
| 10 | + /// </summary> |
| 11 | + public interface ISelectedStorageNode |
| 12 | + { |
| 13 | + /// <summary> |
| 14 | + /// Opens new <see cref="Session"/> with default <see cref="SessionConfiguration"/>. |
| 15 | + /// </summary> |
| 16 | + /// <returns> |
| 17 | + /// New <see cref="Session"/> object. |
| 18 | + /// </returns> |
| 19 | + /// <sample><code> |
| 20 | + /// using (var session = domain.SelectStorageNode(nodeId).OpenSession()) { |
| 21 | + /// // work with persistent objects here. |
| 22 | + /// } |
| 23 | + /// </code></sample> |
| 24 | + /// <seealso cref="Session"/> |
| 25 | + Session OpenSession(); |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// Opens new <see cref="Session"/> of specified <see cref="SessionType"/>. |
| 29 | + /// </summary> |
| 30 | + /// <param name="type">The type of session.</param> |
| 31 | + /// <returns> |
| 32 | + /// New <see cref="Session"/> object. |
| 33 | + /// </returns> |
| 34 | + /// <sample><code> |
| 35 | + /// using (var session = domain.SelectStorageNode(nodeId).OpenSession(sessionType)) { |
| 36 | + /// // work with persistent objects here. |
| 37 | + /// } |
| 38 | + /// </code></sample> |
| 39 | + Session OpenSession(SessionType type); |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// Opens new <see cref="Session"/> with specified <see cref="SessionConfiguration"/>. |
| 43 | + /// </summary> |
| 44 | + /// <param name="configuration">The session configuration.</param> |
| 45 | + /// <returns> |
| 46 | + /// New <see cref="Session"/> object. |
| 47 | + /// </returns> |
| 48 | + /// <sample><code> |
| 49 | + /// using (var session = domain.SelectStorageNode(nodeId).OpenSession(configuration)) { |
| 50 | + /// // work with persistent objects here |
| 51 | + /// } |
| 52 | + /// </code></sample> |
| 53 | + /// <seealso cref="Session"/> |
| 54 | + Session OpenSession(SessionConfiguration configuration); |
| 55 | + |
| 56 | + /// <summary> |
| 57 | + /// Asynchronously opens new <see cref="Session"/> with default <see cref="SessionConfiguration"/>. |
| 58 | + /// </summary> |
| 59 | + /// <returns>A task representing the asynchronous operation.</returns> |
| 60 | + /// <sample><code> |
| 61 | + /// /// var ctSource = new CancellationTokenSource(); |
| 62 | + /// using (var session = await domain.SelectStorageNode(nodeId).OpenSessionAsync(ctSource.Token)) { |
| 63 | + /// // work with persistent objects here. |
| 64 | + /// } |
| 65 | + /// </code></sample> |
| 66 | + /// <seealso cref="Session"/> |
| 67 | + Task<Session> OpenSessionAsync(CancellationToken cancellationToken = default); |
| 68 | + |
| 69 | + /// <summary> |
| 70 | + /// Asynchronously opens new <see cref="Session"/> of specified <see cref="SessionType"/> asynchronously. |
| 71 | + /// </summary> |
| 72 | + /// <param name="type">The type of session.</param> |
| 73 | + /// <returns>A task representing the asynchronous operation.</returns> |
| 74 | + /// <sample><code> |
| 75 | + /// var ctSource = new CancellationTokenSource(); |
| 76 | + /// using (var session = await domain.SelectStorageNode(nodeId).OpenSessionAsync(sessionType, ctSource.Token)) { |
| 77 | + /// // work with persistent objects here. |
| 78 | + /// } |
| 79 | + /// </code></sample> |
| 80 | + Task<Session> OpenSessionAsync(SessionType type, CancellationToken cancellationToken = default); |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// Opens new <see cref="Session"/> with specified <see cref="SessionConfiguration"/> asynchronously. |
| 84 | + /// </summary> |
| 85 | + /// <param name="configuration">The session configuration.</param> |
| 86 | + /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> |
| 87 | + /// <returns>A task representing the asynchronous operation.</returns> |
| 88 | + /// <sample><code> |
| 89 | + /// var ctSource = new CancellationTokenSource(); |
| 90 | + /// using (var session = await domain.SelectStorageNode(nodeId).OpenSessionAsync(configuration, ctSource.Token)) { |
| 91 | + /// // work with persistent objects here |
| 92 | + /// } |
| 93 | + /// </code></sample> |
| 94 | + /// <seealso cref="Session"/> |
| 95 | + Task<Session> OpenSessionAsync(SessionConfiguration configuration, CancellationToken cancellationToken = default); |
| 96 | + } |
| 97 | +} |
0 commit comments