// DELETE: api/Type/5 public HttpResponseMessage Delete(long id) { TypePersistence oTP = new TypePersistence(); HttpResponseMessage oResponse = Request.CreateResponse(oTP.deleteType(id) ? HttpStatusCode.NoContent : HttpStatusCode.NotFound); return(oResponse); }
// GET: api/Type public ArrayList Get() { TypePersistence oTP = new TypePersistence(); ArrayList oTypes = oTP.getTypes(); return(oTypes); }
// PUT: api/Type/5 public HttpResponseMessage Put([FromBody] Models.Type value) { TypePersistence oTP = new TypePersistence(); HttpResponseMessage oResponse = Request.CreateResponse(oTP.putType(value) ? HttpStatusCode.NoContent : HttpStatusCode.NotFound); return(oResponse); }
// GET: api/Type/5 public Models.Type Get(long id) { TypePersistence oTP = new TypePersistence(); Models.Type oType = oTP.getType(id); return(oType); }
public PersistenceEntity(TypePersistence typePersistence, string nameTable, string namePrimaryKey, long valuePrimaryKey) : base(string.Empty) { this.typePersistence = typePersistence; this.nameTable = nameTable; this.namePrimaryKey = namePrimaryKey; this.valuePrimaryKey = valuePrimaryKey; columns = new Dictionary <string, object>(); }
// POST: api/Type public HttpResponseMessage Post([FromBody] Models.Type value) { TypePersistence oTP = new TypePersistence(); long lID = oTP.saveType(value); HttpResponseMessage oResponse = Request.CreateResponse(HttpStatusCode.Created); oResponse.Headers.Location = new Uri(Request.RequestUri, String.Format("{0}", lID)); return(oResponse); }
//En estos metodos set, lo que se hace es, establecer el format que queremos utilizar, y a partir de ahí, según este formato, buscamos //en el diccionario (Los nombres del enum son los mismos que los de los diferentes tipos de persistencia), y si lo encontramos establecemos el formato de persistencia //a utilizar, si no, lanzamos excepción. private static void setPersistenceFormat(TypePersistence formatP) { if (persistenceFormats.Count > 0) { foreach (KeyValuePair <string, Persistence> pair in persistenceFormats) { //(Quitar comentario), seguro que hay una forma mas limpia de hacer esto, pero en el momento no se me ha ocurrido if (pair.Value.ToString() == typeof(Tracker).Namespace + "." + formatP.ToString()) { myP = pair.Value; persistenceFormat = pair.Key; break; } } } else { throw new Exception("Dictionary of Persistences empty"); } }
public static IPersistenceEntity NewPersistenceEntity(TypePersistence typePersistence, string nameTable, string namePrimaryKey, long valuePrimaryKey) { return(new PersistenceEntity(typePersistence, nameTable, namePrimaryKey, valuePrimaryKey)); }
//En path, desde unity, pondríamos application.datapath, para poder guardar las trazas en la carpeta donde //se encuentra el juego. public static void startTracker(string id, string path = "", TypeFile tySerializer = TypeFile.JSONSerializer, TypePersistence tyPersistence = TypePersistence.FilePersistence) { if (id == "editor") { editor = true; uniqueId = Guid.NewGuid().ToString("N"); } else { editor = false; uniqueId = id; } _buffer = new Queue <Trace>(tamBuffer); StartTime = DateTime.Now; //Serializadores addFormat("csv", new CSVSerializer()); addFormat("json", new JSONSerializer()); setSerializeFormat(tySerializer); //Persistencias addPersistenceFormat("File", new FilePersistence()); setPersistenceFormat(tyPersistence); //Path _path = path; if (!Directory.Exists(_path)) { Directory.CreateDirectory(_path); } }