public void SaveConfigInfo() { configInfo = new ConfigInfo();//构造当前的信息 string xml = XmlSerializeHelper.Serialize <ConfigInfo>(configInfo); path = Application.dataPath + "/StreamingAssets/configInfo.xml"; if (File.Exists(path)) { File.Delete(path); } FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } StreamWriter sw = new StreamWriter(path); sw.Write(xml); sw.Flush(); sw.Close(); #if UNITY_EDITOR AssetDatabase.Refresh(); #endif }
private static HttpResponseMessage MakeReturnMessage <T>(T returnMsg) { string res = XmlSerializeHelper.Serialize <T>(returnMsg); return(new HttpResponseMessage { Content = new StringContent(res, Encoding.GetEncoding("UTF-8"), "application/x-www-form-urlencoded") }); }
public virtual List <TEntity> ExecuteSearch <TEntity>(string spName, object criteria, string paramName = "searchCriteria") { string xml = XmlSerializeHelper.Serialize(criteria); var searchCriteria = new SqlParameter { ParameterName = paramName, Value = xml }; return(DbContext.Database.SqlQuery <TEntity>(string.Format("exec {0} @{1}", spName, paramName), searchCriteria).ToList()); }
public override string ConvertInstanceToFile(Shipment Instance, string newFilePath = @"XML\ShipmentResult.xml") { var fPath = string.Empty; if (Instance == null) { MessageBox.Show("请先生成Shipment实例"); } else { var uShipment = new UniversalShipment(); uShipment.Shipment = Instance; var xShipmentString = XmlSerializeHelper.Serialize(uShipment);//让它自己类型推断 //以下为特殊节点进行特殊处理 if (SpecialCollection.Count > 0) { foreach (var coll in SpecialCollection) { var key = coll.Key; var patt = @"<?>[\s\S]+</?>"; patt = patt.Replace("?", key); var reg = new Regex(patt, RegexOptions.IgnoreCase); var matches = reg.Matches(xShipmentString); foreach (Match m in matches) { var xcoll = XElement.Parse(m.Value); var replaceName = coll.Value; foreach (var ele in xcoll.Elements()) { ele.Name = replaceName; } xShipmentString = xShipmentString.Remove(m.Index, m.Value.Length); xShipmentString = xShipmentString.Insert(m.Index, xcoll.ToString()); } } } if (!File.Exists(newFilePath)) { var myFile = File.Create(newFilePath); myFile.Dispose(); myFile.Close(); } using (var sw = new StreamWriter(newFilePath)) { sw.Write(xShipmentString); } fPath = Path.GetFullPath(newFilePath); } return(fPath); }
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 CreateEmptyConfiguration() { RepositoryAnalyserConfiguration configuration = new RepositoryAnalyserConfiguration(); XmlSerializeHelper <RepositoryAnalyserConfiguration> .InitEmptyProperties(configuration); configuration.CurrentLanguage = "en-EN"; configuration.CloneAllBranches = true; configuration.DynamicFiltering = true; configuration.SavingRepositoryPath = LocalizationConstants.DefaultRepositorySavingPath; if (!ZetaLongPaths.ZlpIOHelper.DirectoryExists(LocalizationConstants.ProgramDataApplicationDirectory)) { ZetaLongPaths.ZlpIOHelper.CreateDirectory(LocalizationConstants.ProgramDataApplicationDirectory); } XmlSerializeHelper <RepositoryAnalyserConfiguration> .Serialize(configuration, LocalizationConstants.ConfigFilePath); return(configuration); }
/// <summary> /// 保存配置 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="obj"></param> /// <param name="path"></param> public void SaveConfigInfo <T>(T obj, string path) { string xml = XmlSerializeHelper.Serialize <T>(obj); if (File.Exists(path)) { File.Delete(path); } FileInfo fileInfo = new FileInfo(path); if (!fileInfo.Directory.Exists) { fileInfo.Directory.Create(); } StreamWriter sw = new StreamWriter(path); sw.Write(xml); sw.Flush(); sw.Close(); }
public override string ConvertInstanceToFile(Shipment Instance, string newFilePath = @"XML\ConsolResult.xml") { var fPath = string.Empty; if (Instance == null) { MessageBox.Show("请先生成Shipment实例"); } else { var uShipment = new UniversalShipment(); uShipment.Shipment = Instance; var xShipmentString = XmlSerializeHelper.Serialize(uShipment);//让它自己类型推断 //xShipmentString = Regex.Replace(xShipmentString, @"<UniversalShipment[\s]*>", "<UniversalShipment>"); using (StreamWriter tw = new StreamWriter(newFilePath, false)) { tw.WriteLine(xShipmentString); fPath = Path.GetFullPath(newFilePath); } } return(fPath); }
public void SaveChanges() { XmlSerializeHelper <RepositoryAnalyserConfiguration> .Serialize(Configuration, LocalizationConstants.ConfigFilePath); }