AuScGen.TelerikPlugin.GuiMapParser.LoadGuiMap C# (CSharp) Method

LoadGuiMap() public method

Loads a single GUIMap XML as dictionary collection
public LoadGuiMap ( String filePath ) : Guimap>.Dictionary
filePath String The file path.
return Guimap>.Dictionary
        public Dictionary<String, Guimap> LoadGuiMap(String filePath)
        {
            Logger.Debug("Creating instance of XML Document");
            XmlDocument doc = new XmlDocument();
            Dictionary<String, Guimap> guiObjCollection = null;
            try
            {
                Logger.Debug(string.Concat("Loading the Guimap xml file : [", filePath, "]"));
                doc.Load(filePath);
                XmlNodeList rootNode = doc.DocumentElement.SelectNodes(xmlNodePath);
                //Create a dictionary object that can hold key value pairs of string and GUIMap objects
                guiObjCollection = new Dictionary<string, Guimap>();
                Guimap guimap = null;
                foreach (XmlNode featureSetNode in rootNode)
                {

                    XmlNodeList elementNodes = featureSetNode.ChildNodes;
                    foreach (XmlNode node in elementNodes)
                    {
                        guimap = new Guimap();
                        string logicalName = node.Attributes["name"].InnerText;
                        string identificationType = node.FirstChild.Name;
                        string elementValue = node.FirstChild.InnerText;
                        //Assgin logical name
                        guimap.LogicalName = logicalName;
                        //Save the XML details to a GUIMAP class
                        //identify the identifier && assign the identifier type
                        switch (identificationType.ToLower())
                        {
                            case id:
                                guimap.IdentificationType = identificationType;
                                guimap.Id = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                { 
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                }
                                continue;
                            case name:
                                guimap.IdentificationType = identificationType;
                                guimap.Name = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                {
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                }
                                continue;
                            case xpath:
                                guimap.IdentificationType = identificationType;
                                guimap.Xpath = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                {
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                }
                                continue;
                            case classname:
                                guimap.IdentificationType = identificationType;
                                guimap.ClassName = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                {
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                }
                                continue;
                            case tagname:
                                guimap.IdentificationType = identificationType;
                                guimap.Tagname = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                {
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                } continue;
                            case content:
                                guimap.IdentificationType = identificationType;
                                guimap.Content = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                {
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                }
                                continue;
                            case atribute:
                                guimap.IdentificationType = identificationType;
                                guimap.Atribute = elementValue;
                                //Add the logical name and GUIMap to the Object Collection
                                if (!guiObjCollection.ContainsKey(guimap.LogicalName))
                                {
                                    guiObjCollection.Add(guimap.LogicalName, guimap);
                                } continue;
                        }
                    }
                }
            }
            catch (FileNotFoundException fne)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                Logger.Error("File " + filePath + "not found", fne);
                string message = string.Format("Exception occured while loading the values from Gui map xml {0} not found", filePath);
                Logger.Error(message, fne);
                throw new ResourceException(methodName, message, fne);
            }
            //catch (Exception ex)
            //{
            //    string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            //    string message = "Exception occured while loading the values" +
            //        "from Gui map xml" + filePath + "not found";
            //    Logger.Error(message, ex);
            //    throw new ResourceException(methodName, message, ex);
            //}
            return guiObjCollection;
        }