ACAT.Lib.Core.AbbreviationsManagement.Abbreviations.Load C# (CSharp) Method

Load() public method

Loads abbreviations from the specified file. If filename is null, loads from the default file. Parses the XML file and populates the sorted list
public Load ( String abbreviationsFile = null ) : bool
abbreviationsFile String name of the abbreviations file
return bool
        public bool Load(String abbreviationsFile = null)
        {
            bool retVal = true;

            if (String.IsNullOrEmpty(abbreviationsFile))
            {
                abbreviationsFile = UserManager.GetFullPath(AbbreviationFile);
            }

            var doc = new XmlDocument();

            try
            {
                _abbreviationList.Clear();

                if (File.Exists(abbreviationsFile))
                {
                    doc.Load(abbreviationsFile);

                    var abbrNodes = doc.SelectNodes("/ACAT/Abbreviations/Abbreviation");

                    if (abbrNodes != null)
                    {
                        // load all the abbreviations
                        foreach (XmlNode node in abbrNodes)
                        {
                            createAndAddAbbreviation(node);
                        }
                    }
                }
                else
                {
                    Log.Debug("Abbreviation file " + abbreviationsFile + " does not exist");
                    retVal = false;
                }
            }
            catch (Exception ex)
            {
                Log.Debug("Error processing abbreviations file " + abbreviationsFile + ". Exception: " + ex);
                retVal = false;
            }

            return retVal;
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Loads abbreviations from the abbreviations file
        /// </summary>
        /// <returns></returns>
        public bool Init(String abbreviationsFile = null)
        {
            if (Abbreviations != null)
            {
                Abbreviations.Dispose();
            }

            Abbreviations = new Abbreviations();

            return(Abbreviations.Load(abbreviationsFile));
        }
All Usage Examples Of ACAT.Lib.Core.AbbreviationsManagement.Abbreviations::Load