diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-18 04:28:39 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2016-11-18 04:28:39 -0500 |
| commit | 9f40c1982bf2b63d2779a8971361364772e33298 (patch) | |
| tree | 923d86c9da1aa1ec6c683a21820e4cd9076cd385 /Emby.Server.Implementations/Data/SqliteExtensions.cs | |
| parent | fa714425dd91fed2ca691cd45f73f7ea5a579dff (diff) | |
rework additional repositories
Diffstat (limited to 'Emby.Server.Implementations/Data/SqliteExtensions.cs')
| -rw-r--r-- | Emby.Server.Implementations/Data/SqliteExtensions.cs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Data/SqliteExtensions.cs b/Emby.Server.Implementations/Data/SqliteExtensions.cs index 62615c669..d9536ae9c 100644 --- a/Emby.Server.Implementations/Data/SqliteExtensions.cs +++ b/Emby.Server.Implementations/Data/SqliteExtensions.cs @@ -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(); + } + } } } |
