Skip to content

Commit

Permalink
Wrap AsString
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions committed Nov 6, 2023
1 parent fbef1a0 commit 921b829
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/FishyFlip/Models/FrameCommit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ public FrameCommit(CBORObject obj)
#pragma warning disable CS0618
this.Prev = obj["prev"]?.ToCid();
#pragma warning restore CS0618
this.Rev = obj["rev"]?.AsString();
this.Since = obj["since"]?.AsString();
this.Rev = obj["rev"]?.ToString();
this.Since = obj["since"]?.ToString();
this.Commit = obj["commit"].ToCid();
this.Repo = obj["repo"] is not null ? ATDid.Create(obj["repo"].AsString()) : null;
this.Handle = obj["handle"] is not null ? ATHandle.Create(obj["handle"].AsString()) : null;
this.Rebase = obj["rebase"]?.AsBoolean() ?? false;
this.TooBig = obj["tooBig"]?.AsBoolean() ?? false;
var time = obj["time"]?.AsString();
if (!string.IsNullOrEmpty(time))
{
this.Time = DateTime.Parse(time);
}
this.Time = obj["time"]?.ToDateTime();
}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/FishyFlip/Tools/Cbor/CborExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ internal static class CborExtensions
return null;
}

public static string? ToString(this CBORObject obj)
{
if (obj.IsNull)
{
return null;
}

return obj.AsString();
}

public static DateTime? ToDateTime(this CBORObject obj)
{
if (obj.IsNull)
Expand Down

0 comments on commit 921b829

Please sign in to comment.