/// <summary> /// /// </summary> /// <param name="serializedGameData"></param> public GameDataStorageObject(byte[] serializedGameData) { characterData = new ConcurrentDictionary <string, BaseObject>(); try { string data = System.Text.Encoding.UTF8.GetString(serializedGameData); BaseGameDataStorageObject <string, Tuple <string, string> > descriptors = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Descriptor); BaseGameDataStorageObject <string, Tuple <string, string> > modifiedData = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Descriptor); BaseGameDataStorageObject <string, Tuple <string, string> > extraData = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Descriptor); BaseGameDataStorageObject <string, Tuple <string, int> > attributes = new BaseGameDataStorageObject <string, Tuple <string, int> >(GameDataStorageLayerUtils.objectClassType.Descriptor); BaseGameDataStorageObject <string, Tuple <string, string> > inventoryData = new BaseGameDataStorageObject <string, Tuple <string, string> >(GameDataStorageLayerUtils.objectClassType.Descriptor); string mydata = ""; XDocument xDoc = XDocument.Load(new StringReader(data)); var nameList = from el in xDoc.Root.Descendants("character").Elements("name") select el; var dList = from el in xDoc.Root.Descendants().Elements("attributes").Elements("attribute") where ((string)el.Element("type") != "racial") select new { name = (string)el.Element("name"), bonus = (string)el.Element("bonus"), type = (string)el.Element("type") }; string attPathName = nameList.First().Value + ":attribute"; foreach (var att in dList) { Tuple <string, Tuple <string, int> > tData = new Tuple <string, Tuple <string, int> >(attPathName + ":" + att.type, new Tuple <string, int>(attPathName + ":" + att.name + ":" + att.type, Convert.ToInt32(att.bonus))); attributes.addTupleToList(tData); } Console.WriteLine("Hooray!"); } catch (Exception ex) { string err = ex.Message; Console.WriteLine(err); } //BaseGameDataStorageObject<string, Tuple<string,int>> x = new BaseGameDataStorageObject<string, Tuple<string,int>>(GameDataStorageLayerUtils.objectClassType.Attribute); //Tuple<string, Tuple<string, int>> theData = new Tuple<string, Tuple<string, int>>("test1", new Tuple<string, int>("strength", 25)); //x.insertTupleAt(theData, 0, false); //characterData.TryAdd("test", (BaseObject)x); //Tuple<string, Tuple<string, string>> theData2 = new Tuple<string, Tuple<string, string>>("test1", new Tuple<string, string>("extra strength", "A lot of strength")); //y.insertTupleAt(theData2, 0, false); //characterData.TryAdd("testng", (BaseObject)y); }
/// <summary> /// Insert BaseGameDataStorageObject into a concurrent dictionary /// </summary> /// <typeparam name="TValue1">Templated value type for the first BaseGameDataStorageObject parameter</typeparam> /// <typeparam name="TValue2">Templated value type for the second BaseGameDataStorageObject parameter</typeparam> /// <param name="classType"></param> /// <param name="objectToStore"></param> /// <param name="key"></param> public void insertDataFromSerializedObject <TValue1, TValue2>(GameDataStorageLayerUtils.objectClassType classType, BaseGameDataStorageObject <TValue1, TValue2> objectToStore, string key) { }
/// <summary> /// Searches through the concurrent dictionaries for the object specified and then modifies it on the fly. /// </summary> /// <param name="type">Type of dictionary we should address.</param> /// <param name="obj">Object data to modify</param> /// <returns>True for success, false on failure</returns> public bool modifyData(GameDataStorageLayerUtils.objectClassType type, BaseGameDataStorageObject <string, Tuple <string, int> > obj) { return(true); }