private string GetCalculatedValue(EnumVersionControlOperation operation) { string build = string.Empty; string caminhoXML = this.GetFileVersionControl(); XElement xml = XElement.Load(caminhoXML, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); IEnumerable <XElement> elements = xml.Elements(); foreach (var item in elements.Where(e => e.Attribute("active").Value == "true")) { string attBuild = item.Attribute("build").Value; int version_4 = Conversoes.Inteiro32(attBuild.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)[3]); // init 0 switch (operation) { case EnumVersionControlOperation.Increase: { version_4++; break; } case EnumVersionControlOperation.Decrease: { if (version_4 > 0) { version_4--; } break; } } string version_1_2 = attBuild.Substring(0, attBuild.LastIndexOf(".")); build = string.Format("{0}.{1}", version_1_2, version_4); item.Attribute("build").Value = build; } xml.Save(this.GetFileVersionControl()); return(string.IsNullOrEmpty(build) ? ConfiguracoesIC.VersionValueDefault : build); }
private string GetCalculatedValue(EnumVersionControlOperation operation) { string build = string.Empty; string caminhoXML = this.GetFileVersionControl(); XElement xml = XElement.Load(caminhoXML, LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); IEnumerable<XElement> elements = xml.Elements(); foreach (var item in elements.Where(e => e.Attribute("active").Value == "true")) { string attBuild = item.Attribute("build").Value; int version_4 = Conversoes.Inteiro32(attBuild.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)[3]); // init 0 switch (operation) { case EnumVersionControlOperation.Increase: { version_4++; break; } case EnumVersionControlOperation.Decrease: { if (version_4 > 0) version_4--; break; } } string version_1_2 = attBuild.Substring(0, attBuild.LastIndexOf(".")); build = string.Format("{0}.{1}", version_1_2, version_4); item.Attribute("build").Value = build; } xml.Save(this.GetFileVersionControl()); return string.IsNullOrEmpty(build) ? ConfiguracoesIC.VersionValueDefault : build; }