mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
replaced Json.Serialize with ToJson extension method.
This commit is contained in:
parent
676599c520
commit
8bdf8c31f0
@ -8,7 +8,7 @@ public static class LogEventExtensions
|
||||
{
|
||||
public static string GetHash(this LogEventInfo logEvent)
|
||||
{
|
||||
var stackString = Json.Serialize(logEvent.StackTrace);
|
||||
var stackString = logEvent.StackTrace.ToJson();
|
||||
var hashSeed = String.Concat(logEvent.LoggerName, logEvent.Exception.GetType().ToString(), stackString, logEvent.Level);
|
||||
return HashUtil.CalculateCrc(hashSeed);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ protected override void Write(NLog.LogEventInfo logEvent)
|
||||
dictionary.Add("message", logEvent.GetFormattedMessage());
|
||||
dictionary.Add("ver", _environmentProvider.Version.ToString());
|
||||
|
||||
_logger.Log(Json.Serialize(dictionary));
|
||||
_logger.Log(dictionary.ToJson());
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ public static object Deserialize(string json, Type type)
|
||||
return JsonConvert.DeserializeObject(json, type);
|
||||
}
|
||||
|
||||
public static string Serialize(object obj)
|
||||
public static string ToJson(this object obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using Marr.Data.Converters;
|
||||
using Marr.Data.Mapping;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Converters
|
||||
@ -23,15 +22,14 @@ public object FromDB(ColumnMap map, object dbValue)
|
||||
return null;
|
||||
}
|
||||
|
||||
return Json.Deserialize(stringValue, map.FieldType);
|
||||
return Json.Deserialize(stringValue, map.FieldType);
|
||||
}
|
||||
|
||||
public object ToDB(object clrValue)
|
||||
{
|
||||
if (clrValue == null) return null;
|
||||
|
||||
var json = Json.Serialize(clrValue);
|
||||
return json;
|
||||
return clrValue.ToJson();
|
||||
}
|
||||
|
||||
public Type DbType
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Core.DecisionEngine
|
||||
{
|
||||
@ -110,8 +111,8 @@ private string EvaluateSpec(IRejectWithReason spec, RemoteEpisode remoteEpisode,
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.Data.Add("report", remoteEpisode.Report);
|
||||
e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo);
|
||||
e.Data.Add("report", remoteEpisode.Report.ToJson());
|
||||
e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson());
|
||||
_logger.ErrorException("Couldn't evaluate decision", e);
|
||||
return string.Format("{0}: {1}", spec.GetType().Name, e.Message);
|
||||
}
|
||||
|
@ -6,8 +6,6 @@
|
||||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Tv;
|
||||
using System.Linq;
|
||||
|
@ -80,7 +80,7 @@ public Indexer Create(Indexer indexer)
|
||||
Name = indexer.Name,
|
||||
Enable = indexer.Enable,
|
||||
Implementation = indexer.Implementation,
|
||||
Settings = Json.Serialize(indexer.Settings)
|
||||
Settings = indexer.Settings.ToJson()
|
||||
};
|
||||
|
||||
definition = _indexerRepository.Insert(definition);
|
||||
|
@ -48,7 +48,7 @@ public override IEnumerable<IndexerDefinition> DefaultDefinitions
|
||||
|
||||
private string GetSettings(string url)
|
||||
{
|
||||
return Json.Serialize(new NewznabSettings { Url = url });
|
||||
return new NewznabSettings { Url = url }.ToJson();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> RecentFeed
|
||||
|
@ -71,7 +71,7 @@ public List<Notification> Schema()
|
||||
|
||||
var instanceType = newNotification.Instance.GetType();
|
||||
var baseGenArgs = instanceType.BaseType.GetGenericArguments();
|
||||
newNotification.Settings = (INotifcationSettings) Activator.CreateInstance(baseGenArgs[0]);
|
||||
newNotification.Settings = (INotifcationSettings)Activator.CreateInstance(baseGenArgs[0]);
|
||||
newNotification.Implementation = type.Name;
|
||||
|
||||
notifications.Add(newNotification);
|
||||
@ -85,7 +85,7 @@ public Notification Create(Notification notification)
|
||||
{
|
||||
var definition = new NotificationDefinition();
|
||||
definition.InjectFrom(notification);
|
||||
definition.Settings = Json.Serialize(notification.Settings);
|
||||
definition.Settings = notification.Settings.ToJson();
|
||||
|
||||
definition = _notificationRepository.Insert(definition);
|
||||
notification.Id = definition.Id;
|
||||
@ -97,7 +97,7 @@ public Notification Update(Notification notification)
|
||||
{
|
||||
var definition = _notificationRepository.Get(notification.Id);
|
||||
definition.InjectFrom(notification);
|
||||
definition.Settings = Json.Serialize(notification.Settings);
|
||||
definition.Settings = notification.Settings.ToJson();
|
||||
|
||||
_notificationRepository.Update(definition);
|
||||
|
||||
|
@ -17,9 +17,7 @@ public void should_be_able_to_deserialize_numbers()
|
||||
{
|
||||
var quality = new TypeWithNumbers { Id = 12 };
|
||||
|
||||
var json = Json.Serialize(quality);
|
||||
|
||||
Json.Deserialize<TypeWithNumbers>(json);
|
||||
Json.Deserialize<TypeWithNumbers>(quality.ToJson());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user