internal ErrorNone(ErrorRoot owner, Item item, IdKey idKe) { Owner = owner; Item = item; ErrorId = idKe; owner.Add(this); }
internal ErrorOne(ErrorRoot owner, Item item, IdKey idKe, string text = null) { Owner = owner; Item = item; ErrorId = idKe; _text = text; owner.Add(this); }
public async Task <string> TranslateQuery(string q, string source, string target) { TranslateQuery query = new TranslateQuery(); query.q = q; query.source = source; query.target = target; query.format = "text"; var stringPayload = await Task.Run(() => JsonConvert.SerializeObject(query)); var httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json"); using (var httpClient = new HttpClient()) { HttpResponseMessage httpResponse; try { _logger.LogTrace("Requesting Translation"); httpResponse = await httpClient.PostAsync("https://translation.googleapis.com/language/translate/v2?key=AIzaSyAdnf2VlylP4gobukQHAvDKQmoVh8iT9hE", httpContent); if (httpResponse.Content != null) { string jsonResponse = await httpResponse.Content.ReadAsStringAsync(); return(jsonResponse); } else { throw new Exception("Response content is null!"); } } catch (Exception e) { Error errorMessage = new Error(); errorMessage.code = 1; errorMessage.message = e.Message; ErrorRoot root = new ErrorRoot { error = errorMessage }; string errorJSON = await Task.Run(() => JsonConvert.SerializeObject(root)); return(errorJSON); } } }
internal ErrorNoneAux2(ErrorRoot owner, Item item, Item aux1, Item aux2, IdKey idKe) : base(owner, item, idKe) { Aux1 = aux1; Aux1 = aux2; }
internal ErrorManyAux(ErrorRoot owner, Item item, Item aux1, IdKey idKe, string text = null) : base(owner, item, idKe, text) { Aux = aux1; }
internal ErrorOneAux2(ErrorRoot owner, Item item, Item aux1, Item aux2, IdKey idKe, string text = null) : base(owner, item, idKe, text) { Aux1 = aux1; Aux2 = aux2; }
internal ErrorNoneAux(ErrorRoot owner, Item item, Item aux, IdKey idKe) : base(owner, item, idKe) { Aux = aux; }