/// <summary> /// /// </summary> /// <param name="obj"></param> private void WriteOutMatches(MatchIDList obj) { if (!File.Exists(@"Assets/Resources/MatchIDList/MatchIDList.txt")) { File.Create(@"Assets/Resources/MatchIDList/MatchIDList.txt"); } foreach (string line in File.ReadAllLines(@"Assets/Resources/MatchIDList/MatchIDList.txt")) { foreach (long matchID in obj.IDList) { if (line.Contains(matchID.ToString())) { Debug.LogError("Duplicate Found - MatchID: " + matchID); obj.IDList.Remove(matchID); break; } } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"Assets/Resources/MatchIDList/MatchIDList.txt", true)) { foreach (long matchID in obj.IDList) { Debug.Log("MatchID Written - MatchID: " + matchID); file.WriteLine(matchID); } } }
/// <summary> /// /// </summary> /// <param name="propToValueMap"></param> /// <returns></returns> public static MatchIDList DictionaryToMatchIDList(Dictionary <String, Object> propToValueMap) { MatchIDList matchIDList = new MatchIDList(); #region MatchIDList Property if (propToValueMap[MatchIDList.PropertyNames.MatchIdList] is List <long> ) { matchIDList.IDList = (List <long>)propToValueMap[MatchIDList.PropertyNames.MatchIdList]; } #endregion return(matchIDList); }
/// <summary> /// /// </summary> /// <param name="matchIDList"></param> /// <returns></returns> public static Dictionary <String, Object> MatchIDListToDictionary(MatchIDList matchIDList) { if (matchIDList == null) { throw new ArgumentException("parameter matchIDList is required."); } Dictionary <String, Object> propToValueMap = new Dictionary <String, Object>(); #region MatchIDList Property propToValueMap.Add(MatchIDList.PropertyNames.MatchIdList, matchIDList.IDList); #endregion return(propToValueMap); }
/// <summary> /// Converts a MatchIDList into a dictionary /// </summary> /// <param name="type">Optional - the type of the value parameter</param> /// <param name="value">Optional - the instance that is to be converted into a dictionary</param> /// <returns>A Dictionary containing the data contained in the value parameter</returns> public override Dictionary <String, Object> WriteJson(Type type, Object value) { MatchIDList matchIDList = (MatchIDList)value; return(MatchIDListToDictionary(matchIDList)); }