//public TextStructure FindAuto(string chaine) //{ // try // { // foreach (TextStructure item in this.StructuresLines.Values) // { // if (item.TextMode != TextModeEnum.TXT) continue; // List<TextStructurePart> findautoparts = item.GetFindAutoParts(); // if(findautoparts.Count == 0)continue; // bool isgoodstructure = true; // bon jusqu'a preuve du contraire // foreach (TextStructurePart itempart in findautoparts) // { // if (!TextTools.IsEqualSubstringValue(itempart.Position, itempart.Length, chaine, itempart.DefaultValue)) isgoodstructure = false; // } // if (isgoodstructure) return item; // } // return null; // } // catch (Exception ex) // { // throw new Exception("FindAuto "+ex.Message); // } //} public static List <TextStructure> ExtractStructuresMultiples(DATAVALUES.DataValues DvParamFile) { List <TextStructure> retour = new List <TextStructure>(); try { List <string> structuresName = DvParamFile.ListFieldsName("/param/structures/").ToList(); // on essaye dabord si c'est encapsulé foreach (string structureName in structuresName) { DATAVALUES.DataValues structuredv = null; // extraire la stucture //if (encapsuleNode) structuredv = DvParamFile.CloneDatas("/param/structures/" + structureName + "/", false); //else structuredv = DvParamFile.CloneDatas("/param/" + structureName + "/", false); //!!!m!!! structuredv = ValidateCleanParamPart(structuredv); TextStructure StructureLine = new TextStructure(structuredv, structureName); retour.Add(StructureLine); } return(retour); } catch (Exception) { throw; } }
public void SetStructure(DATAVALUES.DataValues datastruct) { if (datastruct == null) { return; } this.OriginalStructureModel = datastruct; // INFOS string txtmodestr = datastruct.GetString("TextMode"); if (txtmodestr.Equals("CSV", StringComparison.InvariantCultureIgnoreCase)) { this.TextMode = TextModeEnum.CSV; this.TextModeCSVSeparator = ';'; } else if (txtmodestr.Equals("TXT", StringComparison.InvariantCultureIgnoreCase)) { this.TextMode = TextModeEnum.TXT; this.TextModeCSVSeparator = ' '; } string TextModeCSVSeparatorstr = datastruct.GetString("TextModeCSVSeparator"); if (TextModeCSVSeparatorstr.Length > 0) { this.TextModeCSVSeparator = TextModeCSVSeparatorstr[0]; } // PARTIES List <DATAVALUES.DataValuesNode> partsdv = datastruct.GetDatas(DefaultPartsNodes); foreach (DATAVALUES.DataValuesNode item in partsdv) { string namem = item.NodeName; TextStructurePart ipart = this.GetPart(namem); if (ipart == null) { if (string.IsNullOrWhiteSpace(item["position"])) { continue; } ipart = new TextStructurePart(); ipart.Fusion(item); this.Parts.Add(ipart); } else { ipart.Fusion(item, true); } } }
public static DATAVALUES.DataValues ValidateCleanParamPart(DATAVALUES.DataValues fileparamStructure) { // ne peus contenir qu'une seul structure // ne peus pas contenie deux fois la meme position List <DATAVALUES.DataValuesNode> parts = fileparamStructure.GetDatas("/param/parts"); List <string> positions = new List <string>(); foreach (var item in parts) { string pos = item["position"]; if (string.IsNullOrWhiteSpace(pos)) { continue; } if (positions.Contains(pos)) { throw new Exception("Position " + pos + " en doublon"); } positions.Add(pos); } return(fileparamStructure); }
/// <summary> /// Ajouter une nouvelle structure depuis le xml /// </summary> /// <param name="DataStruct"></param> /// <param name="structureName"></param> public void SetStructureXml(DATAVALUES.DataValues DataStruct, string structureName = "default") { this.SetStructure(new TextStructure(DataStruct, structureName)); }
public TextStructure(DATAVALUES.DataValues StructureModel, string structureName = "default") { this.StructureLineName = structureName; this.SetStructure(StructureModel); }