Skip to content

Commit

Permalink
Moved invalid json filter to ItemFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
Stickymaddness committed Aug 20, 2015
1 parent 737ed6a commit f8fff0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
12 changes: 1 addition & 11 deletions POEApi.Model/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected Item(JSONProxy.Item item)
this.H = item.H;
this.IconURL = getIconUrl(item.Icon);
this.League = item.League;
this.Name = filterName(item.Name);
this.Name = item.Name;
this.TypeLine = item.TypeLine;
this.DescrText = item.DescrText;
this.X = item.X;
Expand Down Expand Up @@ -90,16 +90,6 @@ protected Item(JSONProxy.Item item)
this.Character = string.Empty;
}

private string filterName(string jsonName)
{
var items = jsonName.Split(new string[] { ">>" }, StringSplitOptions.None);

if (items.Count() == 1)
return jsonName;

return items[3];
}

private string getIconUrl(string url)
{
Uri uri;
Expand Down
17 changes: 16 additions & 1 deletion POEApi.Model/ItemFactory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using POEApi.Infrastructure;
using System;
using System.Linq;

namespace POEApi.Model
{
Expand All @@ -9,6 +10,9 @@ public static Item Get(JSONProxy.Item item)
{
try
{
item.Name = filterString(item.Name);
item.TypeLine = filterString(item.TypeLine);

if (item.frameType == 4)
return new Gem(item);

Expand All @@ -31,5 +35,16 @@ public static Item Get(JSONProxy.Item item)
throw new Exception(errorMessage);
}
}


private static string filterString(string json)
{
var items = json.Split(new string[] { ">>" }, StringSplitOptions.None);

if (items.Count() == 1)
return json;

return items[3];
}
}
}
}

0 comments on commit f8fff0c

Please sign in to comment.