public ExperimentPermission[] ListExperiments(SessionId sessionId) { JsonData parameters = new JsonData(); parameters["session_id"] = new JsonData(); parameters["session_id"]["id"] = sessionId.Id; JsonData jsonPermissions = PerformCoreRequest("list_experiments", parameters); ExperimentPermission [] experimentPermissions = new ExperimentPermission[jsonPermissions.Count]; for(int i = 0; i < experimentPermissions.Length; ++i) { string name = (string)jsonPermissions[i]["experiment"]["name"]; string category = (string)jsonPermissions[i]["experiment"]["category"]["name"]; double timeAllowed = (double)jsonPermissions[i]["time_allowed"]; experimentPermissions[i] = new ExperimentPermission(name, category, timeAllowed); } return experimentPermissions; }
public Reservation ReserveExperiment(SessionId sessid, string experimentName, string categoryName, string initialData) { return ReserveExperiment(sessid, experimentName, categoryName, initialData, new Dictionary<string, object>()); }
public Reservation ReserveExperiment(SessionId sessid, string experimentName, string categoryName, string initialData, Dictionary<string, object> consumerData) { JsonData parameters = new JsonData(); parameters["session_id"] = new JsonData(); parameters["session_id"]["id"] = sessid.Id; parameters["experiment_id"] = new JsonData(); parameters["experiment_id"]["exp_name"] = experimentName; parameters["experiment_id"]["cat_name"] = categoryName; parameters["client_initial_data"] = initialData; JsonData jsonConsumerData = new JsonData(); foreach(string key in consumerData.Keys){ object v = consumerData[key]; if(v is string) jsonConsumerData[key] = (string)v; else if(v is int) jsonConsumerData[key] = (int)v; else if(v is double) jsonConsumerData[key] = (double)v; else if(v is bool) jsonConsumerData[key] = (bool)v; else if(v is long) jsonConsumerData[key] = (long)v; else throw new ArgumentException("Type of key " + key + " not supported"); } parameters["consumer_data"] = jsonConsumerData.ToJson(); JsonData response = PerformCoreRequest("reserve_experiment", parameters); return parseReservation(response); }
public Reservation ReserveExperiment(SessionId sessid, string experimentName, string categoryName, Dictionary<string, object> consumerData) { return ReserveExperiment(sessid, experimentName, categoryName, "{}", consumerData); }
public Reservation ReserveExperiment(SessionId sessid, string experimentName, string categoryName) { return(ReserveExperiment(sessid, experimentName, categoryName, "{}", new Dictionary <string, object>())); }
public Reservation ReserveExperiment(SessionId sessid, string experimentName, string categoryName, Dictionary <string, object> consumerData) { return(ReserveExperiment(sessid, experimentName, categoryName, "{}", consumerData)); }