Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
umutozel committed Apr 28, 2015
2 parents 04c7ed3 + 73effaa commit 0de8319
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Novaroma.Services/ServiceNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class ServiceNames {
public const string Tvdb = "tvdb";
public const string TvRage = "tvrage";
public const string Freebase = "freebase";
public const string UTorrent = "utorrent";
public const string UTorrent = "bittorrent/utorrent";
public const string ThePirateBay = "thepiratebay";
}
}
75 changes: 47 additions & 28 deletions Novaroma/Model/Search/MediaSearchModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Novaroma.Interface;
Expand Down Expand Up @@ -283,41 +284,41 @@ protected virtual void OnRefreshNeeded() {

protected abstract string SettingName { get; }

#region IConfigurable Members

string IConfigurable.SettingName {
get { return SettingName; }
protected virtual Dictionary<string, object> GetSettingsDictionary() {
return new Dictionary<string, object> {
{ "Downloaded", Downloaded },
{ "Genres", Genres.SelectedItems.Select(g => g) },
{ "NotFound", NotFound },
{ "NotWatched", NotWatched },
{ "VoteCountMax", VoteCountMax },
{ "VoteCountMin", VoteCountMin },
{ "PageSize", PageSize },
{ "Query", Query },
{ "RatingMax", RatingMax },
{ "RatingMin", RatingMin },
{ "ReleaseYearEnd", ReleaseYearEnd },
{ "ReleaseYearStart", ReleaseYearStart },
{ "RuntimeMax", RuntimeMax },
{ "RuntimeMin", RuntimeMin },
{ "SelectedOrderValue", SelectedOrder.Order.Value },
{ "SubtitleDownloaded", SubtitleDownloaded },
{ "SubtitleNotFound", SubtitleNotFound }
};
}

INotifyPropertyChanged IConfigurable.Settings {
get { return this; }
}
protected virtual string SerializeSettings() {
var o = GetSettingsDictionary();

string IConfigurable.SerializeSettings() {
var o = new {
Downloaded,
Genres = Genres.SelectedItems.Select(g => g),
NotFound,
NotWatched,
VoteCountMax,
VoteCountMin,
PageSize,
Query,
RatingMax,
RatingMin,
ReleaseYearEnd,
ReleaseYearStart,
RuntimeMax,
RuntimeMin,
SelectedOrderValue = SelectedOrder.Order.Value,
SubtitleDownloaded,
SubtitleNotFound
};
return JsonConvert.SerializeObject(o);
}

void IConfigurable.DeserializeSettings(string settings) {
protected virtual void DeserializeSettings(string settings) {
var json = (JObject)JsonConvert.DeserializeObject(settings);

SetSettingsFromJson(json);
}

protected virtual void SetSettingsFromJson(JObject json) {
Downloaded = (bool?)json["Downloaded"];
var genres = (IEnumerable)json["Genres"];
genres.OfType<object>().ToList().ForEach(g => {
Expand All @@ -342,6 +343,24 @@ void IConfigurable.DeserializeSettings(string settings) {
SubtitleNotFound = (bool?)json["SubtitleNotFound"];
}

#region IConfigurable Members

string IConfigurable.SettingName {
get { return SettingName; }
}

INotifyPropertyChanged IConfigurable.Settings {
get { return this; }
}

string IConfigurable.SerializeSettings() {
return SerializeSettings();
}

void IConfigurable.DeserializeSettings(string settings) {
DeserializeSettings(settings);
}

#endregion
}
}
15 changes: 14 additions & 1 deletion Novaroma/Model/Search/TvShowSearchModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;

namespace Novaroma.Model.Search {

Expand All @@ -22,5 +24,16 @@ public bool? Ended {
RaisePropertyChanged("Ended");
}
}

protected override Dictionary<string, object> GetSettingsDictionary() {
var d = base.GetSettingsDictionary();
d.Add("Ended", Ended);
return d;
}

protected override void SetSettingsFromJson(JObject json) {
base.SetSettingsFromJson(json);
Ended = (bool?)json["Ended"];
}
}
}

0 comments on commit 0de8319

Please sign in to comment.