replaced Json.Serialize with ToJson extension method.

pull/2/head
Keivan Beigi 12 years ago
parent 676599c520
commit 8bdf8c31f0

@ -8,7 +8,7 @@ namespace NzbDrone.Common.Instrumentation
{
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 @@ namespace NzbDrone.Common.Instrumentation
dictionary.Add("message", logEvent.GetFormattedMessage());
dictionary.Add("ver", _environmentProvider.Version.ToString());
_logger.Log(Json.Serialize(dictionary));
_logger.Log(dictionary.ToJson());
}
}
}

@ -35,7 +35,7 @@ namespace NzbDrone.Common.Serializer
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 @@ namespace NzbDrone.Core.Datastore.Converters
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.DecisionEngine.Specifications.Search;
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 @@ namespace NzbDrone.Core.DecisionEngine
}
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.DataAugmentation.Scene;
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 @@ namespace NzbDrone.Core.Indexers
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 @@ namespace NzbDrone.Core.Indexers.Newznab
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 @@ namespace NzbDrone.Core.Notifications
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 @@ namespace NzbDrone.Core.Notifications
{
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 @@ namespace NzbDrone.Core.Notifications
{
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 @@ namespace NzbDrone.Libraries.Test.JsonTests
{
var quality = new TypeWithNumbers { Id = 12 };
var json = Json.Serialize(quality);
Json.Deserialize<TypeWithNumbers>(json);
Json.Deserialize<TypeWithNumbers>(quality.ToJson());
}
}
}

Loading…
Cancel
Save