d
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SecureString.cs" />
|
||||
<Compile Include="UniquieID.cs" />
|
||||
<Compile Include="UniquiIDStringJsonConverter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
40
Pilz.Cryptography/UniquiIDStringJsonConverter.cs
Normal file
40
Pilz.Cryptography/UniquiIDStringJsonConverter.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Newtonsoft.Json;
|
||||
using Pilz.Cryptography;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Pilz.Json.Converters
|
||||
{
|
||||
public class UniquiIDStringJsonConverter<TargetType> : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return typeof(UniquieID<TargetType>).IsAssignableFrom(objectType);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var idString = serializer.Deserialize<string>(reader);
|
||||
UniquieID<TargetType> id;
|
||||
|
||||
if (existingValue is object)
|
||||
id = (UniquieID<TargetType>)existingValue;
|
||||
else
|
||||
id = new UniquieID<TargetType>();
|
||||
|
||||
id.ID = idString;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
serializer.Serialize(writer, ((UniquieID<TargetType>)value).ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SM64Lib
|
||||
namespace Pilz.Cryptography
|
||||
{
|
||||
public class UniquieID<TargetType>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user