rework additional repositories

This commit is contained in:
Luke Pulverenti
2016-11-18 04:28:39 -05:00
parent fa714425dd
commit 9f40c1982b
8 changed files with 543 additions and 634 deletions

View File

@@ -1,5 +1,7 @@
using System;
using System.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Serialization;
using SQLitePCL.pretty;
namespace Emby.Server.Implementations.Data
@@ -25,7 +27,12 @@ namespace Emby.Server.Implementations.Data
public static byte[] ToGuidParamValue(this string str)
{
return new Guid(str).ToByteArray();
return ToGuidParamValue(new Guid(str));
}
public static byte[] ToGuidParamValue(this Guid guid)
{
return guid.ToByteArray();
}
public static Guid ReadGuid(this IResultSetValue result)
@@ -101,5 +108,24 @@ namespace Emby.Server.Implementations.Data
DateTimeFormatInfo.InvariantInfo,
DateTimeStyles.None).ToUniversalTime();
}
/// <summary>
/// Serializes to bytes.
/// </summary>
/// <returns>System.Byte[][].</returns>
/// <exception cref="System.ArgumentNullException">obj</exception>
public static byte[] SerializeToBytes(this IJsonSerializer json, object obj, IMemoryStreamFactory streamProvider)
{
if (obj == null)
{
throw new ArgumentNullException("obj");
}
using (var stream = streamProvider.CreateNew())
{
json.SerializeToStream(obj, stream);
return stream.ToArray();
}
}
}
}