internal bool TryParseApi(HttpContent content, out ApiVersion1 api) { var success = false; api = new ApiVersion1(); try { var json = JsonConvert.DeserializeObject(Extract(content)) as JObject; var apisJson = json["api-versions"]; foreach (var apiJson in apisJson.AsJEnumerable()) { if (apiJson["name"].Value <string>().Equals("v1")) { foreach (var endpoint in apiJson["endpoints"].AsJEnumerable()) { var name = endpoint["name"].Value <string>(); var location = endpoint["location"].Value <string>(); switch (name) { case "access-token-endpoint": api.AccessTokenEndpoint = location; break; case "seb-configuration-endpoint": api.ConfigurationEndpoint = location; break; case "seb-handshake-endpoint": api.HandshakeEndpoint = location; break; case "seb-log-endpoint": api.LogEndpoint = location; break; case "seb-ping-endpoint": api.PingEndpoint = location; break; } } success = true; } if (!success) { logger.Error("The selected SEB server instance does not support the required API version!"); } } } catch (Exception e) { logger.Error("Failed to parse server API!", e); } return(success); }
public void Initialize(string api, string connectionToken, string examId, string oauth2Token, ServerSettings settings) { this.api = JsonConvert.DeserializeObject <ApiVersion1>(api); this.connectionToken = connectionToken; this.examId = examId; this.oauth2Token = oauth2Token; Initialize(settings); }
public ServerProxy(AppConfig appConfig, ILogger logger) { this.api = new ApiVersion1(); this.appConfig = appConfig; this.cancellationTokenSource = new CancellationTokenSource(); this.httpClient = new HttpClient(); this.logger = logger; this.logContent = new ConcurrentQueue <ILogContent>(); this.timer = new Timer(); }
public ServerProxy( AppConfig appConfig, ILogger logger, IPowerSupply powerSupply = default(IPowerSupply), IWirelessAdapter wirelessAdapter = default(IWirelessAdapter)) { this.api = new ApiVersion1(); this.appConfig = appConfig; this.cancellationTokenSource = new CancellationTokenSource(); this.httpClient = new HttpClient(); this.logContent = new ConcurrentQueue <ILogContent>(); this.logger = logger; this.powerSupply = powerSupply; this.timer = new Timer(); this.wirelessAdapter = wirelessAdapter; }
public ServerProxy( AppConfig appConfig, ILogger logger, IPowerSupply powerSupply = default(IPowerSupply), IWirelessAdapter wirelessAdapter = default(IWirelessAdapter)) { this.api = new ApiVersion1(); this.appConfig = appConfig; this.cancellationTokenSource = new CancellationTokenSource(); this.fileSystem = new FileSystem(appConfig, logger); this.httpClient = new HttpClient(); this.instructionConfirmations = new ConcurrentQueue <string>(); this.logger = logger; this.logContent = new ConcurrentQueue <ILogContent>(); this.parser = new Parser(logger); this.powerSupply = powerSupply; this.timer = new Timer(); this.wirelessAdapter = wirelessAdapter; }