From f5f99753638a0001d06c561f2419231cb8ff46fb Mon Sep 17 00:00:00 2001 From: mschill Date: Mon, 28 Sep 2026 14:15:48 -0400 Subject: [PATCH] =?UTF-8?q?B2026-077=20=E2=80=93=20Update=20Format=20inher?= =?UTF-8?q?itance=20to=20use=20index=20id=20instead=20of=20position/order.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/Formats/fmtall/BASEall.xml | Bin 92194 -> 92198 bytes PROMS/Formats/fmtall/BNPP1Newall.xml | Bin 243848 -> 244284 bytes PROMS/Formats/fmtall/BNPP1all.xml | Bin 185210 -> 185470 bytes PROMS/Formats/fmtall/BNPP2all.xml | Bin 199362 -> 199398 bytes PROMS/Formats/fmtall/BNPPsamall.xml | Bin 170438 -> 170474 bytes PROMS/Formats/fmtall/CPBCKNHC_00all.xml | Bin 23046 -> 23074 bytes PROMS/Formats/fmtall/CPBCKNHCall.xml | Bin 55138 -> 55166 bytes PROMS/Formats/fmtall/CPBCK_00all.xml | Bin 23038 -> 23066 bytes PROMS/Formats/fmtall/CPBCKall.xml | Bin 55178 -> 55206 bytes PROMS/Formats/fmtall/EPTST1all.xml | Bin 62450 -> 62520 bytes PROMS/Formats/fmtall/EXP2all.xml | Bin 82768 -> 82802 bytes PROMS/Formats/fmtall/PROMSDemo1all.xml | Bin 99538 -> 99574 bytes PROMS/Formats/fmtall/PROMSDemo2all.xml | Bin 83234 -> 83270 bytes PROMS/Formats/fmtall/PROMSMan1all.xml | Bin 85094 -> 85130 bytes PROMS/Formats/fmtall/PROMSMan2all.xml | Bin 82766 -> 82802 bytes PROMS/Formats/fmtall/RNPAOPBCKNHCall.xml | Bin 51762 -> 51790 bytes PROMS/Formats/fmtall/SUMall.xml | Bin 128934 -> 128962 bytes PROMS/Formats/fmtall/TUECall.xml | Bin 124082 -> 124110 bytes PROMS/Formats/fmtall/vcb1all.xml | Bin 108544 -> 108580 bytes PROMS/Formats/fmtall/vcb2all.xml | Bin 82186 -> 82222 bytes PROMS/Formats/fmtall/vcbaall.xml | Bin 98506 -> 98540 bytes PROMS/Formats/fmtall/vcbeppall.xml | Bin 92196 -> 92232 bytes PROMS/Formats/fmtall/wst2all.xml | Bin 90604 -> 90640 bytes PROMS/Formats/fmtall/wstdcsall.xml | Bin 113520 -> 113592 bytes PROMS/Formats/fmtall/wstsamall.xml | Bin 90074 -> 90110 bytes .../VEPROMS.CSLA.Library/Format/vlnFormat.cs | 555 ++++++------------ 26 files changed, 177 insertions(+), 378 deletions(-) diff --git a/PROMS/Formats/fmtall/BASEall.xml b/PROMS/Formats/fmtall/BASEall.xml index cb86c004e014660806ed0a2459dd64621b0275ce..03e05a2a81e6e5a888566628806860f918617522 100644 GIT binary patch delta 52 zcmV-40L%ZP&;_Q@1+d)y0ST8K2mvRv0{<`$lfa!Mx0V_K9s`r4Bodb@2muPWObr1p K4Y#}<0cJ`TIuXbK delta 54 zcmV-60LlNR&;_E<1+d)ymmmlMCbIX!?aX qCY9+6Dwqtm-`K*m4n;bc>Du&+T&VPPptMB$zimw0|7~OLVgvx$3N3d4 delta 70 zcmV-M0J;CX^bUye4uFIKv;uCim&RKHD3{Q~0%Vt9r2;mWu!{l?w_vgY=mD4hiUP8? ckhKD?0hd~h0$`VrwE`H2vbX}bvbY0^0b}nT^Z)<= diff --git a/PROMS/Formats/fmtall/BNPP1all.xml b/PROMS/Formats/fmtall/BNPP1all.xml index 1e852979510272e5696d8a6c97d147e1b5255cdf..2353f22c5ba8ebcc2b300280871aaaa0480369a9 100644 GIT binary patch delta 74 zcmeyhjQigT?uHh|Eldug(_I9al%_ZQWE9vQAj-6Y3BjMPaGc3zdcuE3o9Q0}nGQ^U Yc8yVJ+FeGc>8GwTN^E~4!PK`403HAxPyhe` delta 54 zcmV-60LlOUs0;e03xI?Hv;sgCm#_{3jJNI;0xSZS%mEOWQ1SsbmmmZJW|#2a0Wg=! M)d3i{@EHP*x>he0&;S4c diff --git a/PROMS/Formats/fmtall/BNPP2all.xml b/PROMS/Formats/fmtall/BNPP2all.xml index f7193fd06bab7f9443c02a6111415adb9bf70535..2ca61c97ebf60de5693eea4450453d9aae916584 100644 GIT binary patch delta 43 zcmV+`0M!4&l?>*U41k0IlmZBsM9cvem%jP|440n$0TPzD0UDP60b+%e0=1L_E((S? B5bOW| delta 35 tcmV+;0NnrPl?=j_41k0IlmZBsI;;UGmyq-UnwP-b0S<-y0=4`D>In>P4^{vG diff --git a/PROMS/Formats/fmtall/BNPPsamall.xml b/PROMS/Formats/fmtall/BNPPsamall.xml index 859124648432b231348bb0e68cd8d79ddeaee276..5feb6a455a3d3f797f1288b4cc8a28d60ef23abb 100644 GIT binary patch delta 46 zcmV+}0MY-(vkL073V^f$EY6qGp8*z^*6#rhmnh2t5SD)d7?+yJ0c4lT!T~n7?#=<& E%J2sjdjJ3c delta 27 jcmaF0nd{hQu7)j)I_IW~G&5>UpLK#UW&53TjC`j7uagW) diff --git a/PROMS/Formats/fmtall/CPBCKNHC_00all.xml b/PROMS/Formats/fmtall/CPBCKNHC_00all.xml index daa3a4ef215c69b8d51d76e252d28b9d710a373b..00ac98ef0788f7c6ace59666ca55fc8372db78dd 100644 GIT binary patch delta 22 ecmZqM!nkM);|3+?$(QV8CJWe$Y&LVgAO-+uoCt3K delta 18 acmZ3qg|Tf5;|3+?$rsc`HU~Lh5CZ^82M2Tj diff --git a/PROMS/Formats/fmtall/CPBCKNHCall.xml b/PROMS/Formats/fmtall/CPBCKNHCall.xml index ddac1c5aa5c6db9c6801387ef43a88750b005cbc..1560795a63e0ac71140d2fc8678a42d4c2c55ae3 100644 GIT binary patch delta 22 ecmaE~j``m@<_%4SlMQlZCg+X(mo diff --git a/PROMS/Formats/fmtall/CPBCK_00all.xml b/PROMS/Formats/fmtall/CPBCK_00all.xml index bb7bcd6763f79e407147de35b799a9de3c797515..60ab874771cb0f7dd54db78c75469551b7e29053 100644 GIT binary patch delta 21 dcmeyjnQ_(@#tkCQlMmU+OtKf*tl@l33;<}Z2&Vu5 delta 18 acmbQWh4J5J#tkCQlMkqiY<6+JCI$dcD+j#* diff --git a/PROMS/Formats/fmtall/CPBCKall.xml b/PROMS/Formats/fmtall/CPBCKall.xml index d476b8b5f2e4cc7d1d61096e3e6a5929d812a18a..a4e06a166d96258cee8ccf6ed1ebf20b64705adf 100644 GIT binary patch delta 22 ecmeBL&%A6s^M<~{$u_w%llQrcY+h9OA{790{R&$E delta 18 acmZ3sp1Es1^M<~{$shDYHt#EZkqQ7*gb6qR diff --git a/PROMS/Formats/fmtall/EPTST1all.xml b/PROMS/Formats/fmtall/EPTST1all.xml index 148469dde4b4730181ff02c6960ffb2d10d9f3eb..346cba3b9afcf4f3465c053677958be730e5d7bf 100644 GIT binary patch delta 43 ycmezLoO#C!<_%A(Ca1-SOukUYxA{rc2d2p>F=8Oj%LlemsHl9e8_`kGd#6EzT& delta 18 acmey=#(JTRb%WHb$q7?>HlLWaY6SpSTM4%S diff --git a/PROMS/Formats/fmtall/PROMSDemo1all.xml b/PROMS/Formats/fmtall/PROMSDemo1all.xml index fdd07f1021a4a0e2cc5d7f6bacf6d1a68a5b6f0d..5cc382ba3735d47cb3b2dac402bc609bd8fd9dc5 100644 GIT binary patch delta 30 ocmV+(0O9}Ai3awG2Czh}lQf?elSV8Klc-iGlb)(%v(T*q*VP#g7ytkO delta 18 acmey?$#$ueZG+3&$!j7tHcwcab{zm%G6{76 diff --git a/PROMS/Formats/fmtall/PROMSDemo2all.xml b/PROMS/Formats/fmtall/PROMSDemo2all.xml index a5d4598ca7619e54d21934896fdc3304dd3bdd36..e760c3589969047df1085f738d714d8506a627b7 100644 GIT binary patch delta 34 qcmZ3~#d@rZb;GHi$tKY%laF-@Ojc;GnVivRHhDw4+~!ri725$5xM~-HXF<_VVqnr&1|#6lB^W~fiw!7 diff --git a/PROMS/Formats/fmtall/PROMSMan2all.xml b/PROMS/Formats/fmtall/PROMSMan2all.xml index 328704cac3fa0286001fa3a1fc89afa877a3f437..73a74ad9909f4f9548ecc36a05f1155f8b94d44e 100644 GIT binary patch delta 36 scmX@t#`>v^b%VsL$)Bc)ak?=iGUPB6Go(&t+$1{LAy;Cv!z{j)00t)wRR910 delta 18 acmey=#(J)eb%VsL$#GM9HlLWaY6SpS7YVTd diff --git a/PROMS/Formats/fmtall/RNPAOPBCKNHCall.xml b/PROMS/Formats/fmtall/RNPAOPBCKNHCall.xml index d9537e6ff8b099c480d18340406506279f28ed80..bb4b182ae04e076843011558fe592dd329e31908 100644 GIT binary patch delta 22 ecmdlqh56hR<_-S}CdcK-OrDb?vRSB5Arb(3ZV99S delta 18 acmX>%g?ZBy<_-S}CM#%(Y}PAOhy(yowFij+ diff --git a/PROMS/Formats/fmtall/SUMall.xml b/PROMS/Formats/fmtall/SUMall.xml index 0cfbc9024d2f330d94a599ac727400864dd1aa87..26d914b2ce9488b4d52f0dea06e5fe08b130d7d8 100644 GIT binary patch delta 21 dcmZ4Xp8e2!_6=DJCY2a8*Dcsyw}4S28~}Tq3OfJ* delta 22 ecmX@~o_*PS_6=DJCZ`mNG|yVFebxd-jc@>lfeN_* diff --git a/PROMS/Formats/fmtall/TUECall.xml b/PROMS/Formats/fmtall/TUECall.xml index b6297644dd216a5d660c7c067895b62449285c58..af1dba24a593eec273a6a178ac24f03217acdf25 100644 GIT binary patch delta 22 ecmdmVlKtFC_6-j8ljk%WG>6o052J+XkHtlM`Y!Ci^X!HCd;RZ?nQimhS+fOAF2b diff --git a/PROMS/Formats/fmtall/vcb2all.xml b/PROMS/Formats/fmtall/vcb2all.xml index cd54bac287c2a09e4cffbcdab3dd149b6653955d..1cc36f829dacffbbb0b05658d3ae32be4fd93be8 100644 GIT binary patch delta 46 zcmV+}0MY-7f(5RE1+X-SleAnGlSl*%lg4%ulQ1n9lWu#OlYn6klPH1^leRHxvwnz- ExUB6H1poj5 delta 18 ZcmZ42#M;%wy1}G diff --git a/PROMS/Formats/fmtall/vcbaall.xml b/PROMS/Formats/fmtall/vcbaall.xml index b6cc732549dd6b1ba636e31874e5bef657e34872..0294a52abd5bdf94e0da3484de3574bda707a2ee 100644 GIT binary patch delta 38 wcmV+>0NMY_fd=e>2C!zUlahZTlNu@vlfYCQlfbBClkA^1lT4-_vqr3h)LLB1+coLlAnx|K$$kPprxq7fmaLW diff --git a/PROMS/Formats/fmtall/wst2all.xml b/PROMS/Formats/fmtall/wst2all.xml index 6ab56c916e7d415615c17ef17dc6a7284836f084..70708e0e42749a2bcd4c4d79c3ab7d73a3603427 100644 GIT binary patch delta 34 scmV+-0NwxW!v&DU1+bK(lXP+xlXjdAlXj30lMr4SlklKovmm6*y&y6WfB*mh delta 18 acmbPmg!Ro~)(uk@Po5B=vH8JbgM9#8NC~_E diff --git a/PROMS/Formats/fmtall/wstdcsall.xml b/PROMS/Formats/fmtall/wstdcsall.xml index 52b549777660d5c7830bb67855b1fe74f8c96302..92aa7050c3e10da22fc68119e8b39e31c65e3e75 100644 GIT binary patch delta 51 zcmV-30L=gJ_6E532Cx#HlWLSAlk~Jilh9fmvv8e)0+aNPB$M{E5R*VrJd?nh9D`b* Jw_2b978|nZ7@q(D delta 59 zcmV-B0L1^e_XhCx2Cx#HlPX>ilYq1`lh9fmlOTj7lfarVv*?{J0+Uo#Oq0Nx9FwMz RHk0t09)tFvxAvd`!WvZp9PI!A diff --git a/PROMS/Formats/fmtall/wstsamall.xml b/PROMS/Formats/fmtall/wstsamall.xml index 73202e14cd46f9d9255aa7e7c98c4235f5177963..f437a02281db93c741f0da66712e1117b1c042c4 100644 GIT binary patch delta 45 zcmV+|0Mh^3zXkrk1+Y4$lN6#B2Sxy40BitrlP{tdlMsFwlSG!9lVE-hlAsW?8m7Rx DpED9f delta 18 acmeyjpY_&$)(uumC+~~Y*xa_XViy2kKnc Loop {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path); - tmpNode = xmlNode; - // RHM 20090831 Try doing a lookup of the parent. If no parent, go back to the original and do an inheritance lookup - XmlAttribute attr = xmlNode.Attributes["ParentType"]; + //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Loop {0},{1}", xmlNode.Name == "Step" ? "Step." + xmlNode.Attributes["Type"].Value : xmlNode.Name, path); + // RHM 20090831 Try doing a lookup of the parent. If no parent, go back to the original and do an inheritance lookup + XmlAttribute attr = xmlNode.Attributes["ParentType"]; if (attr == null || attr.Value == string.Empty) // Cannot find ParentType so do an InheritanceLookup return InheritLookup(tmpNode2, path, true); - //return InheritLookup(xmlNode, path, false); xmlNode = xmlNode.ParentNode.SelectSingleNode(string.Format("Step[@Type='{0}']", xmlNode.Attributes["ParentType"].InnerText)); - // Based upon our current data - the following conditions are never met. - //if (xmlNode == null && path.StartsWith("Font")) - //{ - // //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Font {0},{1}", tmpNode.Name == "Step" ? "Step." + tmpNode.Attributes["Type"].Value : tmpNode.Name, path); - // return LookupSingleFontNode(tmpNode, path); - //} - //if (xmlNode == null) - //{ - // //if (path.Contains("Font")) Console.WriteLine("vlnFormatDocument.LookupSingleStepNode -> Font {0},{1}", tmpNode2.Name == "Step" ? "Step." + tmpNode2.Attributes["Type"].Value : tmpNode2.Name, path); - // return InheritLookup(tmpNode2, path, true); - //} xn = xmlNode.SelectSingleNode(path); } return xn; @@ -145,38 +97,20 @@ namespace VEPROMS.CSLA.Library } public static string Lookup(XmlNode xmlNode, string path) { - //if (xmlNode == null) return null; XmlNode xn = LookupSingleNode(xmlNode, path); - //if (xn == null) xn = InheritLookup(xmlNode, path); - if (xn == null) return null; - return xn.InnerText; - } - //public static string StepLookup(XmlNode xmlNode, string path) - //{ - // //if (xmlNode == null) return null; - // XmlNode xn = LookupSingleStepNode(xmlNode, path); - // //if (xn == null) xn = InheritLookup(xmlNode, path); - // if (xn == null) return null; - // return xn.InnerText; - //} - public static T EnumLookup(XmlNode xmlNode, string path) + return xn?.InnerText; + } + public static T EnumLookup(XmlNode xmlNode, string path) { string str = Lookup(xmlNode,path); - if (str == null) return default(T); - return (T)Enum.Parse(typeof(T), str); - } - public static int? IntLookup(XmlNode xmlNode, string path) + return str == null ? default : (T)Enum.Parse(typeof(T), str); + } + public static int? IntLookup(XmlNode xmlNode, string path) { - //if (xmlNode == null) return null; - //XmlNode xn = LookupSingleNode(xmlNode, path); - //if (xn == null) xn = InheritLookup(xmlNode, path); - //if (xn == null) return null; - //return int.Parse(xn.InnerText); string str = Lookup(xmlNode, path); - if (str == null) return null; - return int.Parse(str); - } - public static int SiblingCount(XmlNode xmlNode) + return str == null ? null : (int?)int.Parse(str); + } + public static int SiblingCount(XmlNode xmlNode) { int retval = 0; string nodeName = xmlNode.Name; @@ -189,22 +123,32 @@ namespace VEPROMS.CSLA.Library public static string Path(XmlNode xmlNode) { // Walk the path - string parentPath = (xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode)); + string parentPath = xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode); // Count Siblings with the Same Name int sibCount = SiblingCount(xmlNode); return string.Format("{0}/{1}[{2}]", parentPath, xmlNode.Name, sibCount); } - public static XmlNode InheritLookup(XmlNode xmlNode, string path, bool stepLookup) + //B2026-077 – Update Format inheritance to use index id instead of position/order. + public static string PathByIndex(XmlNode xmlNode) + { + if (xmlNode.Name == "TransTypes" || xmlNode.Name == "Step") + { + string parentPath = xmlNode.ParentNode == xmlNode.OwnerDocument ? "" : Path(xmlNode.ParentNode); + string Indx = xmlNode.Attributes["Index"].Value; + return $@"{parentPath}/{xmlNode.Name}[@Index='{Indx}']"; + } + else + { + return Path(xmlNode); + } + } + public static XmlNode InheritLookup(XmlNode xmlNode, string path, bool stepLookup) { //stepLookup = false; // 8/2 change for inheritance if (xmlNode == null) return null;// No path to match - string xPath = Path(xmlNode);// Build xPath from xmlNode - if (xmlNode.Name == "TransTypes") - { - string TransIndex = xmlNode.Attributes["Index"].Value; - xPath = System.Text.RegularExpressions.Regex.Replace(xPath, @"\[[0-9]*\]$", @"[@Index='" + TransIndex + @"']"); - } - vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument - This also ties it to a FormatInfo object + string xPath = PathByIndex(xmlNode);// Build xPath from xmlNode + + vlnFormatDocument fd = (vlnFormatDocument)xmlNode.OwnerDocument;//First Get the vlnFormatDocument - This also ties it to a FormatInfo object while(fd.MyFormat.MyIParent != null) { fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument @@ -215,8 +159,8 @@ namespace VEPROMS.CSLA.Library else xp = fd.SelectSingleNode(xPath);// Get the related node if (xp != null) { - XmlNode xn = null; - if (stepLookup) + XmlNode xn; + if (stepLookup) { //if (path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", xp.Name == "Step" ? "Step." + xp.Attributes["Type"].Value : xp.Name, path); xn = LookupSingleStepNode(xp, path); @@ -233,14 +177,14 @@ namespace VEPROMS.CSLA.Library { if (xmlNode == null) return null;// No path to match string xPath = Path(xmlNode);// Build xPath from xmlNode - vlnFormatDocument fd = (vlnFormatDocument)(xmlNode.OwnerDocument);//First Get the vlnFormatDocument - This also ties it to a FormatInfo object + vlnFormatDocument fd = (vlnFormatDocument)xmlNode.OwnerDocument;//First Get the vlnFormatDocument - This also ties it to a FormatInfo object while (fd.MyFormat.MyIParent != null) { fd = fd.MyFormat.MyIParent.PlantFormat.XmlDoc;// Get the parents vlnFormatDocument if (fd != null) { XmlNode xp = fd.SelectSingleNode(xPath);// Get the related node - if (xp != null) + if (xp != null) { XmlNodeList xl = xp.SelectNodes(path); if (xl != null && xl.Count > 0) @@ -256,100 +200,41 @@ namespace VEPROMS.CSLA.Library [TypeConverter(typeof(ExpandableObjectConverter))] public class vlnFormatItem { - public vlnFormatItem(XmlNode xmlNode) - { - _XmlNode = xmlNode; - } - public vlnFormatItem() { } - XmlNode _XmlNode; - internal XmlNode XmlNode - { - get { return _XmlNode; } - set { _XmlNode = value; } - } - private IFormatOrFormatInfo _MyFormat; + public vlnFormatItem(XmlNode xmlNode) => XmlNode = xmlNode; + public vlnFormatItem() { } + + internal XmlNode XmlNode { get; set; } + private IFormatOrFormatInfo _MyFormat; public IFormatOrFormatInfo MyFormat { get { if (_MyFormat == null) { - vlnFormatDocument doc = (XmlNode.OwnerDocument) as vlnFormatDocument; - if(doc != null) - _MyFormat = doc.MyFormat; - } + if (XmlNode.OwnerDocument is vlnFormatDocument doc) + _MyFormat = doc.MyFormat; + } return _MyFormat; } } - private IFormatOrFormatInfo _MyParentFormat; - public IFormatOrFormatInfo MyParentFormat + public IFormatOrFormatInfo MyParentFormat => MyFormat.MyIParent; + public virtual string GetPDDisplayName() => ToString(); + public virtual string GetPDName() => ToString(); + public virtual string GetPDDescription() => ToString(); + public virtual string GetPDCategory() => ToString(); + public XmlNodeList SelectNodes(string path) => vlnFormatDocument.LookupNodes(XmlNode, path); + public XmlNode SelectSingleNode(string path) { - get - { - return MyFormat.MyIParent; - } - } - public virtual string GetPDDisplayName() - { return ToString(); } - public virtual string GetPDName() - { return ToString(); } - public virtual string GetPDDescription() - { return ToString(); } - public virtual string GetPDCategory() - { return ToString(); } - public XmlNodeList SelectNodes(string path) - { - return vlnFormatDocument.LookupNodes(_XmlNode, path); - } - public XmlNode SelectSingleNode(string path) - { - //AdjustLookup(_XmlNode, path); //if(path.Contains("Font")) Console.WriteLine("vlnFormatItem.SelectSingleNode {0},{1}", _XmlNode.Name == "Step" ? "Step." + _XmlNode.Attributes["Type"].Value : _XmlNode.Name, path); - return vlnFormatDocument.LookupSingleNode(_XmlNode, path); + return vlnFormatDocument.LookupSingleNode(XmlNode, path); } - //public static string _LookUpNode; - //private static void AdjustLookup(XmlNode xmlNode,string path) - //{ - // if (xmlNode.Name == "Step") - // { - // XmlAttribute attr = xmlNode.Attributes["Type"]; - // if (attr != null) _LookUpNode = attr.Value; - // //Console.WriteLine("AdjustLookup Type = {0}/{1}", _LookUpNode, path); - // } - // else - // { - // //Console.WriteLine("AdjustLookup {0}", xmlNode.Name); - // } - //} - public XmlNode SelectSingleFontNode(string path) - { - return vlnFormatDocument.LookupSingleFontNode(_XmlNode, path); - } - public string Lookup(string path) - { - return vlnFormatDocument.Lookup(_XmlNode, path); - } - public string Lookup(string path, ref string local) - { - return (local != null? local : local = Lookup(path)); - } - //public string StepLookup(string path) - //{ - // return vlnFormatDocument.StepLookup(_XmlNode, path); - //} - public int? IntLookup(string path) - { - return vlnFormatDocument.IntLookup(_XmlNode, path); - } - public int? IntLookup(string path, ref int? local) - { - return (local != null ? local : local = IntLookup(path)); - } - public T EnumLookup(string path) - { - return vlnFormatDocument.EnumLookup(_XmlNode, path); - } - public bool LazyLoad(ref LazyLoad ll, string xPath) + public XmlNode SelectSingleFontNode(string path) => vlnFormatDocument.LookupSingleFontNode(XmlNode, path); + public string Lookup(string path) => vlnFormatDocument.Lookup(XmlNode, path); + public string Lookup(string path, ref string local) => local ?? (local = Lookup(path)); + public int? IntLookup(string path) => vlnFormatDocument.IntLookup(XmlNode, path); + public int? IntLookup(string path, ref int? local) => local != null ? local : local = IntLookup(path); + public T EnumLookup(string path) => vlnFormatDocument.EnumLookup(XmlNode, path); + public bool LazyLoad(ref LazyLoad ll, string xPath) { if (ll == null) { @@ -358,12 +243,9 @@ namespace VEPROMS.CSLA.Library } return ll.Value; } - protected static bool RetrieveBool(XmlNode xn) - { - return xn != null && xn.InnerText.ToUpper() == "TRUE"; - } - // a LaxyLoad that allows you to pass in the default setting - public bool LazyLoad(ref LazyLoad ll, string xPath, bool defaultReturn) + protected static bool RetrieveBool(XmlNode xn) => xn != null && xn.InnerText.ToUpper() == "TRUE"; + // a LazyLoad that allows you to pass in the default setting + public bool LazyLoad(ref LazyLoad ll, string xPath, bool defaultReturn) { if (ll == null) { @@ -372,12 +254,9 @@ namespace VEPROMS.CSLA.Library } return ll.Value; } - // if nothing is set for this node, then use the passed in default value - protected static bool RetrieveBool(XmlNode xn, bool defaultReturn) - { - return (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn; - } - public string LazyLoad(ref LazyLoad ll, string xPath) + // if nothing is set for this node, then use the passed in default value + protected static bool RetrieveBool(XmlNode xn, bool defaultReturn) => (xn != null) ? xn.InnerText.ToUpper() == "TRUE" : defaultReturn; + public string LazyLoad(ref LazyLoad ll, string xPath) { if (ll == null) { @@ -386,16 +265,13 @@ namespace VEPROMS.CSLA.Library } return ll.Value; } - protected static string RetrieveString(XmlNode xn) - { - return xn != null ? xn.InnerText : null; - } - public string MyPath + protected static string RetrieveString(XmlNode xn) => xn?.InnerText; + public string MyPath { get { StringBuilder sb = new StringBuilder(); - XmlNode node = _XmlNode; + XmlNode node = XmlNode; string prefix = ""; while (node != null) { @@ -429,14 +305,13 @@ namespace VEPROMS.CSLA.Library int? value = null; if (xn != null) { - int iValue = 0; - if (!int.TryParse(xn.InnerText, out iValue)) - { - if (xn.InnerText == "") return null; - Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText)); - throw (new Exception(string.Format("{0} = '{1}' could not be converted to int?", xPath, xn.InnerText))); - } - value = iValue; + if (!int.TryParse(xn.InnerText, out int iValue)) + { + if (xn.InnerText == "") return null; + Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to int?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText)); + throw new Exception(string.Format("{0} = '{1}' could not be converted to int?", xPath, xn.InnerText)); + } + value = iValue; } return value; } @@ -445,13 +320,12 @@ namespace VEPROMS.CSLA.Library float? value = null; if (xn != null) { - float fValue = 0; - if (!float.TryParse(xn.InnerText, out fValue)) - { - Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to float?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText)); - throw (new Exception(string.Format("{0} = '{1}' could not be converted to float?", xPath, xn.InnerText))); - } - value = fValue; + if (!float.TryParse(xn.InnerText, out float fValue)) + { + Console.WriteLine(string.Format("'{0}'\r\n'{1}'\r\n'{2}' could not be converted to float?", MyFormat.FullName, MyPath + "/" + xPath, xn.InnerText)); + throw new Exception(string.Format("{0} = '{1}' could not be converted to float?", xPath, xn.InnerText)); + } + value = fValue; } return value; } @@ -460,9 +334,8 @@ namespace VEPROMS.CSLA.Library { if (ll == null) { - XmlNode xn = this._XmlNode; - xn = SelectSingleNode(xPath); - if (xn == null) + XmlNode xn = SelectSingleNode(xPath); + if (xn == null) ll = new LazyLoad(null); else if (xn.Value == "")// No value specified - Use zero value if it is defined - GetName returns a null if it is not defined ll = new LazyLoad>(Enum.GetName(typeof(T), 0) != null ? (Nullable) Enum.Parse(typeof(T), "0") : null); @@ -497,17 +370,10 @@ namespace VEPROMS.CSLA.Library #region LazyLoad public class LazyLoad { - public LazyLoad(T value) - { - _Value = value; - } - private T _Value; - public T Value - { - get { return _Value; } - set { _Value = value; } - } - } + public LazyLoad(T value) => Value = value; + + public T Value { get; set; } + } #endregion #region vlnFormatList, new() public class vlnFormatList : List, ICustomTypeDescriptor @@ -522,9 +388,11 @@ namespace VEPROMS.CSLA.Library _XmlNodeList = value; foreach (XmlNode xn in _XmlNodeList) { - T tt = new T(); - tt.XmlNode = xn; - Add(tt); + T tt = new T + { + XmlNode = xn + }; + Add(tt); } } } @@ -546,7 +414,7 @@ namespace VEPROMS.CSLA.Library XmlNode node = _XmlNodeList[0]; // Get the first node in a list vlnFormatDocument doc = null; if (node != null) - doc = (node.OwnerDocument) as vlnFormatDocument; // Get the owner document as a vlnFormatDocument + doc = node.OwnerDocument as vlnFormatDocument; // Get the owner document as a vlnFormatDocument if (doc != null) _MyFormat = doc.MyFormat; // Get the Format associated with the vlnFormatDocument } @@ -557,36 +425,24 @@ namespace VEPROMS.CSLA.Library _MyFormat = value; } } - #region ICustomTypeDescriptor - public String GetClassName() - { return TypeDescriptor.GetClassName(this, true); } - public AttributeCollection GetAttributes() - { return TypeDescriptor.GetAttributes(this, true); } - public String GetComponentName() - { return TypeDescriptor.GetComponentName(this, true); } - public TypeConverter GetConverter() - { return TypeDescriptor.GetConverter(this, true); } - public EventDescriptor GetDefaultEvent() - { return TypeDescriptor.GetDefaultEvent(this, true); } - public PropertyDescriptor GetDefaultProperty() - { return TypeDescriptor.GetDefaultProperty(this, true); } - public object GetEditor(Type editorBaseType) - { return TypeDescriptor.GetEditor(this, editorBaseType, true); } - public EventDescriptorCollection GetEvents(Attribute[] attributes) - { return TypeDescriptor.GetEvents(this, attributes, true); } - public EventDescriptorCollection GetEvents() - { return TypeDescriptor.GetEvents(this, true); } - public object GetPropertyOwner(PropertyDescriptor pd) - { return this; } - public PropertyDescriptorCollection GetProperties(Attribute[] attributes) - { return GetProperties(); } - public virtual PropertyDescriptorCollection GetProperties() + #region ICustomTypeDescriptor + public string GetClassName() => TypeDescriptor.GetClassName(this, true); + public AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true); + public string GetComponentName() => TypeDescriptor.GetComponentName(this, true); + public TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true); + public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true); + public PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true); + public object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true); + public EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true); + public EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true); + public object GetPropertyOwner(PropertyDescriptor pd) => this; + public PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties(); + public virtual PropertyDescriptorCollection GetProperties() { // Create a collection object to hold property descriptors PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); - // Iterate the list - int i = 0; - for (i = 0; i < this.Count; i++) + // Iterate the list + for (int i = 0; i < Count; i++) { // Create a property descriptor for the item and add to the property descriptor collection pds.Add(new vlnPropertyDescriptor, T>(this, i)); @@ -601,13 +457,10 @@ namespace VEPROMS.CSLA.Library public class vlnIndexedFormatList : vlnFormatList, ICustomTypeDescriptor where T : vlnFormatItem,IVlnIndexedFormatItem, new() { - public vlnIndexedFormatList(XmlNodeList xmlNodeList,IFormatOrFormatInfo myFormat) : base(xmlNodeList) - { - MyFormat = myFormat; - } - public vlnIndexedFormatList() : base() { } - public virtual vlnIndexedFormatList InheritedList { get { return null; } } - public new T this[int index] + public vlnIndexedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) : base(xmlNodeList) => MyFormat = myFormat; + public vlnIndexedFormatList() : base() { } + public virtual vlnIndexedFormatList InheritedList => null; + public new T this[int index] { get { @@ -620,8 +473,6 @@ namespace VEPROMS.CSLA.Library if (ttlParent != null) return ttlParent[index]; return null; - // None found - Can I find it in another format? - return null; } } public int MaxIndex @@ -657,36 +508,25 @@ namespace VEPROMS.CSLA.Library return max; } } - #region ICustomTypeDescriptor - public String GetClassName() - { return TypeDescriptor.GetClassName(this, true); } - public AttributeCollection GetAttributes() - { return TypeDescriptor.GetAttributes(this, true); } - public String GetComponentName() - { return TypeDescriptor.GetComponentName(this, true); } - public TypeConverter GetConverter() - { return TypeDescriptor.GetConverter(this, true); } - public EventDescriptor GetDefaultEvent() - { return TypeDescriptor.GetDefaultEvent(this, true); } - public PropertyDescriptor GetDefaultProperty() - { return TypeDescriptor.GetDefaultProperty(this, true); } - public object GetEditor(Type editorBaseType) - { return TypeDescriptor.GetEditor(this, editorBaseType, true); } - public EventDescriptorCollection GetEvents(Attribute[] attributes) + #region ICustomTypeDescriptor + public new string GetClassName() => TypeDescriptor.GetClassName(this, true); + public new AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true); + public new string GetComponentName() => TypeDescriptor.GetComponentName(this, true); + public new TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true); + public new EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true); + public new PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true); + public new object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true); + public new EventDescriptorCollection GetEvents(Attribute[] attributes) { return TypeDescriptor.GetEvents(this, attributes, true); } - public EventDescriptorCollection GetEvents() - { return TypeDescriptor.GetEvents(this, true); } - public object GetPropertyOwner(PropertyDescriptor pd) - { return this; } - public PropertyDescriptorCollection GetProperties(Attribute[] attributes) - { return GetProperties(); } - public virtual PropertyDescriptorCollection GetProperties() + public new EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true); + public new object GetPropertyOwner(PropertyDescriptor pd) => this; + public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties(); + public new virtual PropertyDescriptorCollection GetProperties() { // Create a collection object to hold property descriptors PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); // Iterate the list - int i = 0; - for (i = 0; i < this.Count; i++) + for (int i = 0; i < Count; i++) { // Create a property descriptor for the item and add to the property descriptor collection pds.Add(new vlnPropertyDescriptor, T>(this, i)); @@ -701,14 +541,11 @@ namespace VEPROMS.CSLA.Library public class vlnNamedFormatList : vlnFormatList, ICustomTypeDescriptor where T : vlnFormatItem, IVlnNamedFormatItem, new() { - public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) - : base(xmlNodeList) - { - MyFormat = myFormat; - } - public vlnNamedFormatList() : base() { } - public virtual vlnNamedFormatList InheritedList { get { return null; } } - public new T this[string name] + public vlnNamedFormatList(XmlNodeList xmlNodeList, IFormatOrFormatInfo myFormat) + : base(xmlNodeList) => MyFormat = myFormat; + public vlnNamedFormatList() : base() { } + public virtual vlnNamedFormatList InheritedList => null; + public T this[string name] { get { @@ -721,8 +558,6 @@ namespace VEPROMS.CSLA.Library if (ttlParent != null) return ttlParent[name]; return null; - // None found - Can I find it in another format? - return null; } } public new T this[int index] @@ -735,47 +570,27 @@ namespace VEPROMS.CSLA.Library if (ttlParent != null) return ttlParent[index]; return null; - // None found - Can I find it in another format? - return null; } } - public new int Count - { - get - { - return base.Count; - } - } - #region ICustomTypeDescriptor - public String GetClassName() - { return TypeDescriptor.GetClassName(this, true); } - public AttributeCollection GetAttributes() - { return TypeDescriptor.GetAttributes(this, true); } - public String GetComponentName() - { return TypeDescriptor.GetComponentName(this, true); } - public TypeConverter GetConverter() - { return TypeDescriptor.GetConverter(this, true); } - public EventDescriptor GetDefaultEvent() - { return TypeDescriptor.GetDefaultEvent(this, true); } - public PropertyDescriptor GetDefaultProperty() - { return TypeDescriptor.GetDefaultProperty(this, true); } - public object GetEditor(Type editorBaseType) - { return TypeDescriptor.GetEditor(this, editorBaseType, true); } - public EventDescriptorCollection GetEvents(Attribute[] attributes) - { return TypeDescriptor.GetEvents(this, attributes, true); } - public EventDescriptorCollection GetEvents() - { return TypeDescriptor.GetEvents(this, true); } - public object GetPropertyOwner(PropertyDescriptor pd) - { return this; } - public PropertyDescriptorCollection GetProperties(Attribute[] attributes) - { return GetProperties(); } - public virtual PropertyDescriptorCollection GetProperties() + public new int Count => base.Count; + #region ICustomTypeDescriptor + public new string GetClassName() => TypeDescriptor.GetClassName(this, true); + public new AttributeCollection GetAttributes() => TypeDescriptor.GetAttributes(this, true); + public new string GetComponentName() => TypeDescriptor.GetComponentName(this, true); + public new TypeConverter GetConverter() => TypeDescriptor.GetConverter(this, true); + public new EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true); + public new PropertyDescriptor GetDefaultProperty() => TypeDescriptor.GetDefaultProperty(this, true); + public new object GetEditor(Type editorBaseType) => TypeDescriptor.GetEditor(this, editorBaseType, true); + public new EventDescriptorCollection GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true); + public new EventDescriptorCollection GetEvents() => TypeDescriptor.GetEvents(this, true); + public new object GetPropertyOwner(PropertyDescriptor pd) => this; + public new PropertyDescriptorCollection GetProperties(Attribute[] attributes) => GetProperties(); + public new virtual PropertyDescriptorCollection GetProperties() { // Create a collection object to hold property descriptors PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); // Iterate the list - int i = 0; - for (i = 0; i < this.Count; i++) + for (int i = 0; i < Count; i++) { // Create a property descriptor for the item and add to the property descriptor collection pds.Add(new vlnPropertyDescriptor, T>(this, i)); @@ -793,16 +608,16 @@ namespace VEPROMS.CSLA.Library { private string Plural(string name) { - if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies"; - if (name.EndsWith("ss")) return name + "es"; - else return name + "s"; + if (name.EndsWith("y")) return $"{name.Substring(0, name.Length - 1)}ies"; + if (name.EndsWith("ss")) return $"{name}es"; + else return $"{name}s"; } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { - if (destType == typeof(string) && value is T) + if (destType == typeof(string) && value is T vart) { // Return department and department role separated by comma. - return ((T)value).Count.ToString() + " " + (((T)value).Count == 1 ? typeof(C).Name : Plural(typeof(C).Name)); + return $"{vart.Count} {(vart.Count == 1 ? typeof(C).Name : Plural(typeof(C).Name))}"; } return base.ConvertTo(context, culture, value, destType); } @@ -815,17 +630,16 @@ namespace VEPROMS.CSLA.Library { private string Plural(string name) { - if (name.EndsWith("y")) return name.Substring(0, name.Length - 1) + "ies"; - if (name.EndsWith("ss")) return name + "es"; - if (name.EndsWith("x")) return name + "es"; - else return name + "s"; - } + if (name.EndsWith("y")) return $"{name.Substring(0, name.Length - 1)}ies"; + if (name.EndsWith("ss")) return $"{name}es"; + return name.EndsWith("x") ? $"{name}es" : $"{name}s"; + } public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) { - if (destType == typeof(string) && value is T) + if (destType == typeof(string) && value is T vart) { // Return department and department role separated by comma. - return ((T)value).MaxIndex.ToString() + " " + (((T)value).MaxIndex == 1 ? typeof(C).Name : Plural(typeof(C).Name)); + return $"{vart.MaxIndex} {(vart.MaxIndex == 1 ? typeof(C).Name : Plural(typeof(C).Name))}"; } return base.ConvertTo(context, culture, value, destType); } @@ -837,38 +651,23 @@ namespace VEPROMS.CSLA.Library where C : vlnFormatItem, new() { protected C _Item = null; - public vlnPropertyDescriptor(T itemList, int index) - : base("#" + index.ToString(), null) - { - _Item = itemList[index]; - } - public override bool CanResetValue(object component) - { return true; } - public override Type ComponentType - { get { return _Item.GetType(); } } - public override object GetValue(object component) - { return _Item; } - public override bool IsReadOnly - { get { return true; } } - public override Type PropertyType - { get { return _Item.GetType(); } } - public override void ResetValue(object component) + public vlnPropertyDescriptor(T itemList, int index) + : base("#" + index.ToString(), null) => _Item = itemList[index]; + public override bool CanResetValue(object component) => true; + public override Type ComponentType => _Item.GetType(); + public override object GetValue(object component) => _Item; + public override bool IsReadOnly => true; + public override Type PropertyType => _Item.GetType(); + public override void ResetValue(object component) { ;} - public override bool ShouldSerializeValue(object component) - { return true; } - public override void SetValue(object component, object value) + public override bool ShouldSerializeValue(object component) => true; + public override void SetValue(object component, object value) { /*_Item = value*/;} - //public override AttributeCollection Attributes - //{ get { return new AttributeCollection(null); } } - public override string DisplayName - { get { return _Item.GetPDDisplayName(); } } - public override string Description - { get { return _Item.GetPDDescription(); } } - public override string Name - { get { return _Item.GetPDName(); } } - public override string Category - { get { return _Item.GetPDCategory(); } } - } // Class + public override string DisplayName => _Item.GetPDDisplayName(); + public override string Description => _Item.GetPDDescription(); + public override string Name => _Item.GetPDName(); + public override string Category => _Item.GetPDCategory(); + } // Class #endregion }