-
Notifications
You must be signed in to change notification settings - Fork 9
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 #68 from teknologi-umum/dotnet-8
Upgrade to .NET 8
- Loading branch information
Showing
39 changed files
with
353 additions
and
514 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
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
using System; | ||
using System.Collections.Immutable; | ||
using System.Threading.Tasks; | ||
using BotNet.GrainInterfaces; | ||
using Orleans; | ||
|
||
namespace BotNet.Grains { | ||
public class TrackedMessageGrain : Grain, ITrackedMessageGrain { | ||
private string? _sender; | ||
private string? _text; | ||
private long? _replyToMessageId; | ||
|
||
public Task TrackMessageAsync(string sender, string text, long? replyToMessageId) { | ||
_sender = sender; | ||
_text = text; | ||
_replyToMessageId = replyToMessageId; | ||
DelayDeactivation(TimeSpan.FromHours(1)); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public async Task<(string? Sender, string? Text, long? ReplyToMessageId)> GetMessageAsync() { | ||
DelayDeactivation(TimeSpan.FromHours(1)); | ||
return (_sender, _text, _replyToMessageId); | ||
} | ||
|
||
public async Task<ImmutableList<(string Sender, string Text)>> GetThreadAsync(int maxLines) { | ||
if (_sender is null || _text is null) return ImmutableList<(string Sender, string Text)>.Empty; | ||
|
||
ImmutableList<(string Sender, string Text)>.Builder builder = ImmutableList.Create((_sender, _text)).ToBuilder(); | ||
|
||
long? messageId = _replyToMessageId; | ||
for (int i = 1; messageId.HasValue && i < maxLines; i++) { | ||
ITrackedMessageGrain repledToMessageGrain = GrainFactory.GetGrain<ITrackedMessageGrain>(messageId.Value); | ||
(string? sender, string? text, messageId) = await repledToMessageGrain.GetMessageAsync(); | ||
if (sender is not null && text is not null) { | ||
builder.Add((sender, text)); | ||
} | ||
} | ||
|
||
DelayDeactivation(TimeSpan.FromHours(1)); | ||
return builder.ToImmutableList(); | ||
} | ||
} | ||
} | ||
using System.Threading.Tasks; | ||
using BotNet.GrainInterfaces; | ||
using Orleans; | ||
|
||
namespace BotNet.Grains { | ||
public class TrackedMessageGrain : Grain, ITrackedMessageGrain { | ||
private string? _sender; | ||
private string? _text; | ||
private long? _replyToMessageId; | ||
|
||
public Task TrackMessageAsync(string sender, string text, long? replyToMessageId) { | ||
_sender = sender; | ||
_text = text; | ||
_replyToMessageId = replyToMessageId; | ||
DelayDeactivation(TimeSpan.FromHours(1)); | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task<(string? Sender, string? Text, long? ReplyToMessageId)> GetMessageAsync() { | ||
DelayDeactivation(TimeSpan.FromHours(1)); | ||
return Task.FromResult((_sender, _text, _replyToMessageId)); | ||
} | ||
|
||
public async Task<ImmutableList<(string Sender, string Text)>> GetThreadAsync(int maxLines) { | ||
if (_sender is null || _text is null) return []; | ||
|
||
ImmutableList<(string Sender, string Text)>.Builder builder = ImmutableList.Create((_sender, _text)).ToBuilder(); | ||
|
||
long? messageId = _replyToMessageId; | ||
for (int i = 1; messageId.HasValue && i < maxLines; i++) { | ||
ITrackedMessageGrain repledToMessageGrain = GrainFactory.GetGrain<ITrackedMessageGrain>(messageId.Value); | ||
(string? sender, string? text, messageId) = await repledToMessageGrain.GetMessageAsync(); | ||
if (sender is not null && text is not null) { | ||
builder.Add((sender, text)); | ||
} | ||
} | ||
|
||
DelayDeactivation(TimeSpan.FromHours(1)); | ||
return builder.ToImmutableList(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.