-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#255 - Serialization version using converters.
- Loading branch information
Showing
5 changed files
with
39 additions
and
14 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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
<small class="text-muted"> | ||
<span>Client</span> | ||
<span> | ||
<Version Value="@Client" /> | ||
<ConvertToString Value="@Client" /> | ||
</span> | ||
|
||
@if (Api != null) | ||
{ | ||
<span>Api</span> | ||
<span> | ||
<Version Value="@Api" /> | ||
<ConvertToString Value="@Api" /> | ||
</span> | ||
} | ||
</small> |
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
28 changes: 28 additions & 0 deletions
28
src/Money.UI.Blazor/Services/Converters/VersionConverter.cs
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,28 @@ | ||
using Neptuo.Converters; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Money.Services.Converters | ||
{ | ||
public class VersionConverter : DefaultConverter<Version, string> | ||
{ | ||
public override bool TryConvert(Version sourceValue, out string targetValue) | ||
{ | ||
targetValue = null; | ||
if (sourceValue != null) | ||
{ | ||
string text = sourceValue.Revision == 0 | ||
? sourceValue.ToString(3) | ||
: sourceValue.ToString(4); | ||
|
||
targetValue = $"v{text}"; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |