-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from s2quake/feature/node-client-content
Client/Node ContentBase class
- Loading branch information
Showing
16 changed files
with
173 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace LibplanetConsole.Client; | ||
|
||
public abstract class ClientContentBase(string name) : IClientContent, IDisposable | ||
{ | ||
private readonly string _name = name; | ||
private bool _isDisposed; | ||
|
||
protected ClientContentBase() | ||
: this(string.Empty) | ||
{ | ||
} | ||
|
||
public string Name => _name != string.Empty ? _name : GetType().Name; | ||
|
||
void IDisposable.Dispose() | ||
{ | ||
OnDispose(disposing: true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
Task IClientContent.StartAsync(CancellationToken cancellationToken) | ||
=> OnStartAsync(cancellationToken); | ||
|
||
Task IClientContent.StopAsync(CancellationToken cancellationToken) | ||
=> OnStopAsync(cancellationToken); | ||
|
||
protected abstract Task OnStartAsync(CancellationToken cancellationToken); | ||
|
||
protected abstract Task OnStopAsync(CancellationToken cancellationToken); | ||
|
||
protected virtual void OnDispose(bool disposing) | ||
{ | ||
if (!_isDisposed) | ||
{ | ||
if (disposing) | ||
{ | ||
// do nothing | ||
} | ||
|
||
_isDisposed = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace LibplanetConsole.Client; | ||
|
||
public interface IClientContent | ||
{ | ||
string Name { get; } | ||
|
||
Task StartAsync(CancellationToken cancellationToken); | ||
|
||
Task StopAsync(CancellationToken cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace LibplanetConsole.Node; | ||
|
||
public interface INodeContent | ||
{ | ||
string Name { get; } | ||
|
||
Task StartAsync(CancellationToken cancellationToken); | ||
|
||
Task StopAsync(CancellationToken cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.