diff --git a/HoloXPLOR/HoloXPLOR.csproj b/HoloXPLOR/HoloXPLOR.csproj
index a662d4b..b8ae932 100644
--- a/HoloXPLOR/HoloXPLOR.csproj
+++ b/HoloXPLOR/HoloXPLOR.csproj
@@ -51,8 +51,8 @@
..\packages\Dolkens.Framework.1.0.5648.17179\lib\net45\Dolkens.Framework.dll
True
-
- ..\packages\Dolkens.Framework.Caching.0.1.5560.19205\lib\net45\Dolkens.Framework.Caching.dll
+
+ ..\packages\Dolkens.Framework.Caching.0.1.5617.32687\lib\net45\Dolkens.Framework.Caching.dll
True
@@ -87,6 +87,7 @@
..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll
True
+
diff --git a/HoloXPLOR/Models/HoloTable/DetailModel.cs b/HoloXPLOR/Models/HoloTable/DetailModel.cs
index ff574a8..96e624e 100644
--- a/HoloXPLOR/Models/HoloTable/DetailModel.cs
+++ b/HoloXPLOR/Models/HoloTable/DetailModel.cs
@@ -12,43 +12,55 @@
using System.Xml;
using System.Xml.Serialization;
using System.Text;
+using Dolkens.Framework.Caching;
namespace HoloXPLOR.Models.HoloTable
{
public class DetailModel
{
+ public String CacheKey { get { return CacheUtils.BuildCacheKey("DetailModel.Player", this._currentXML.ToLowerInvariant()); } }
+
public DetailModel(String id, Guid? shipID = null)
{
this._currentXML = id;
- String filename = HttpContext.Current.Server.MapPath(String.Format(@"~/App_Data/Inventory/{0}.xml", this.CurrentXML));
+ this.Player = CacheUtils.Cache.Get(this.CacheKey) as Inventory.Player;
- // Special locatio for samples
- if (Path.GetFileNameWithoutExtension(filename) == "sample")
+ if (this.Player == null)
{
- filename = HttpContext.Current.Server.MapPath(String.Format(@"~/App_Data/{0}.xml", this.CurrentXML));
+ String filename = HttpContext.Current.Server.MapPath(String.Format(@"~/App_Data/Inventory/{0}.xml", this.CurrentXML));
+
+ // Special locatio for samples
+ if (Path.GetFileNameWithoutExtension(filename) == "sample")
+ {
+ filename = HttpContext.Current.Server.MapPath(String.Format(@"~/App_Data/{0}.xml", this.CurrentXML));
+ }
+
+ if (File.Exists(filename))
+ {
+ this.Player = System.IO.File.ReadAllText(filename).FromXML();
+ }
+ else
+ {
+ throw new FileNotFoundException("Unable to load specified xml", String.Format("{0}.xml", id));
+ }
}
- if (File.Exists(filename))
+ if (this.Player != null)
{
- this.Player = System.IO.File.ReadAllText(filename).FromXML();
this.ShipID = shipID ?? Guid.Empty;
-
if (shipID.HasValue && !this.Player.Ships.Where(s => s.ID == this.ShipID).Any())
{
throw new FileNotFoundException("Unable to load specified ship from xml", String.Format("{0}.xml", id));
}
-
var shipItemIDs = new HashSet(this.Player.Ships.Where(s => s.Inventory != null).Where(s => s.Inventory.Items != null).SelectMany(s => s.Inventory.Items).Select(i => i.ID));
this.Player.Inventory = new Inventory.Inventory
{
Items = this.Player.Items.Where(i => !shipItemIDs.Contains(i.ID)).Select(i => new Inventory.InventoryItem { ID = i.ID }).ToArray()
};
- }
- else
- {
- throw new FileNotFoundException("Unable to load specified xml", String.Format("{0}.xml", id));
+
+ CacheUtils.Cache.Add(this.CacheKey, this.Player, DateTime.Now.AddMinutes(15));
}
}
@@ -84,6 +96,8 @@ public void Save()
xw.Close();
}
}
+
+ CacheUtils.Cache.Add(this.CacheKey, this.Player, DateTime.Now.AddMinutes(15));
}
public Byte[] GetBytes()
diff --git a/HoloXPLOR/packages.config b/HoloXPLOR/packages.config
index 1181c35..4d60303 100644
--- a/HoloXPLOR/packages.config
+++ b/HoloXPLOR/packages.config
@@ -4,7 +4,7 @@
-
+