/// <summary> /// Delete Object /// </summary> /// <param name="obj">Object to delete</param> /// <returns></returns> public APIResponse Delete(APIObject obj) { Id = obj.id; LastResponseTotalItem = 1; return(SetObject(obj.GetType(), null, "DELETE")); }
Stream(APIObject obj) { m_dataObjs.Add(new Snoop.Data.ClassSeparator(typeof(APIObject))); m_dataObjs.Add(new Snoop.Data.Bool("Is read-only", obj.IsReadOnly)); // derived classes will get picked up by CollectorExts }
/// <summary> /// Add object /// </summary> /// <param name="obj">Object to add</param> /// <param name="parent">Parent object if needed</param> /// <returns></returns> public APIResponse AddObject(IAPIObject obj, APIObject parent) { obj.SetParentId(parent.id); string json = obj.Serialize(); if (obj.IsParentIdRequired()) { ParentId = parent.id; } LastResponseTotalItem = 1; return(SetObject(obj.GetType(), json, "POST")); }
public APIObject setFoo(string _foo) { long tempGlobalTimestamp = globalTimestamp.getTimestamp(); if (tempGlobalTimestamp == long.MaxValue || tempGlobalTimestamp == localTimestamp) { apiObject.setFoo(_foo); return(apiObject); } else { apiObject = apiObject.copy(); apiObject.setFoo(_foo); localTimestamp = tempGlobalTimestamp; return(apiObject); } }
Collect(System.Object obj) { m_dataObjs.Clear(); if (obj == null) { return; } APIObject tmpObj = obj as APIObject; if (tmpObj != null) { Stream(tmpObj); } // now that we've collected all the data that we know about, // fire an event to any registered Snoop Collector Extensions so // they can add their data FireEvent_CollectExt(obj); }
/// <summary> /// Update object /// </summary> /// <param name="obj">modified object</param> /// <param name="parent">Parent object if needed</param> /// <returns></returns> public APIResponse UpdateObject(IAPIObject obj, APIObject parent = null) { var result = new APIResponse(); if (obj == null) { return(result); } LastResponseTotalItem = 1; string json = obj.Serialize(); Id = ((APIObject)obj).id; if (obj.IsParentIdRequired()) { ParentId = parent.id; } return(SetObject(obj.GetType(), json, "PUT")); }
private void Stream(APIObject obj) { m_dataObjs.Add(new Snoop.Data.ClassSeparator(typeof(APIObject))); m_dataObjs.Add(new Snoop.Data.Bool("Is read-only", obj.IsReadOnly)); // derived classes will get picked up by CollectorExts }
public SendReturn(APIObject obj) : base(obj) { }
public static void GetCheckDirectory() { Console.WriteLine("Checking if our Data Directory Exists."); if (!Directory.Exists(APIObject.DataDirectoryPath)) { //If the directory for our basecode json file doesn't exist we create it along with the json file. DirectoryInfo dir = Directory.CreateDirectory(APIObject.DataDirectoryPath); Console.WriteLine("Directory didn't exists. It's been constructed."); } Console.WriteLine("Checking if our data base exists."); if (!CodeExists()) { Console.WriteLine("Data data non existing. Downloading."); //if the directory exists but the file doesn't, we create the file. using (var client = new WebClient()) { client.DownloadFile("https://mtgjson.com/json/AllSets.sqlite", $"{APIObject.BuildFilePath(APIObject.MTGDataBase)}"); } } }
private static bool CodeExists() { return(File.Exists(APIObject.BuildFilePath(APIObject.MTGDataBase))); }