Exemplo n.º 1
0
        // Load substitutions
        private void LoadBuildSubstitution(XmlNode p)
        {
            // Get the standard attributes for substitution
            string rule      = GetXmlAttr(p, "RuleNumber");
            string startYear = GetXmlAttr(p, "StartYear");
            string delimiter = GetXmlAttr(p, "Delimiter");

            // Avoid user errors
            if (int.TryParse(rule, out int ruleNumber) && ushort.TryParse(startYear, out ushort year) && delimiter.Length == 1)
            {
                // Sub Substitution rule in Index class
                IJPSubstitutionRule sr = (IJPSubstitutionRule)ijp.GetSubstitutionRule(ruleNumber);
                // Set the start year in the substitution rule
                sr.StartYear = year;

                // Load the individual rules
                foreach (XmlNode c in p.ChildNodes)
                {
                    if (c is XmlWhitespace)
                    {
                        continue;
                    }
                    switch (c.Name)
                    {
                    case "Rule":
                        if (Enum.TryParse(GetXmlAttr(c, "Type"), true, out MsgToXml.Ba type))
                        {
                            SetSubValues(sr, type, c, delimiter);
                        }
                        else
                        {
                            Log?.Invoke(this, $"Unknown substitution rule type =>{GetXmlAttr(c, "Type")}<=");
                        }
                        break;
                    }
                }
                ijp.SetSubstitutionRule(sr);
            }
        }