private void OnCallback(string data) { try { var response = CultureInfo.InvariantCulture.DoInCulture(() => XmlSerializeHelper.Deserialize(data)); if (!response.IsSuccess) { SendOutError(response.Exception); return; } var type = response.GetType(); this.AddDebugLog(type.Name); var handler = _handlerBunch.TryGetValue(response.GetType()); if (handler != null) { handler(response); } } catch (Exception ex) { SendOutError(ex); } }
/// <summary> /// List all project for certain language /// </summary> /// <returns></returns> public IEnumerable <ProjectDto> ListProjects(string lang) { if (String.IsNullOrEmpty(lang)) { return(null); } // bad practice, better send path from web layer for specified repository only var path = HttpContext.Current.Server.MapPath(String.Format("~/App_Data/Projects_{0}.xml", lang)); if (!File.Exists(path)) { return(null); } try { var text = File.ReadAllText(path); var data = XmlSerializeHelper.Deserialize <ProjectDtoCollection>(text); return(data.Items); } catch (Exception) { // log error return(null); } }
private BaseResponse SendCommand(BaseCommandMessage command, bool throwError = true) { var commandXml = XmlSerializeHelper.Serialize(command); var result = XmlSerializeHelper.Deserialize(_client.SendCommand(commandXml)); if (!result.IsSuccess) { this.AddErrorLog(LocalizedStrings.Str3514Params, command.Id, result.Text); if (throwError) { throw new InvalidOperationException(result.Text); } } return(result); }
private RepositoryAnalyserConfiguration LoadConfigurationFromFile() { try { RepositoryAnalyserConfiguration configuration; if (ZetaLongPaths.ZlpIOHelper.FileExists(LocalizationConstants.ConfigFilePath)) { configuration = XmlSerializeHelper <RepositoryAnalyserConfiguration> .Deserialize( LocalizationConstants.ConfigFilePath); } else { configuration = CreateEmptyConfiguration(); } return(configuration); } catch (Exception) { //todo loging return(this.CreateEmptyConfiguration()); } }
private void OnCallback(string data) { try { var response = CultureInfo.InvariantCulture.DoInCulture(() => XmlSerializeHelper.Deserialize(data)); if (!response.IsSuccess) { SendOutError(response.Exception); return; } var type = response.GetType(); SessionHolder.AddDebugLog(type.Name); SessionHolder.ProcessResponse(response); } catch (Exception ex) { SendOutError(ex); } }
/// <summary> /// Convert xml to object /// </summary> /// <param name="xml"></param> /// <returns></returns> public static T Parse <T>(string xml) where T : Response { return(XmlSerializeHelper.Deserialize <T>(xml)); //var jResponse = ToJObject(xml); //return JsonConvert.DeserializeObject<T>(jResponse["response"].ToString()); }