public static void LoadFromXmlFile(this Dictionary <int, List <ParameterReplaceAction> > actions, string fileName, int portalId, bool portalSpecific, ref List <string> messages)
        {
            if (messages == null)
            {
                throw new ArgumentNullException("messages");
            }

            messages = new List <string>();
            if (File.Exists(fileName))
            {
                var rdr = new XmlTextReader(fileName)
                {
                    XmlResolver   = null,
                    DtdProcessing = DtdProcessing.Prohibit,
                };
                while (rdr.Read())
                {
                    switch (rdr.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (rdr.Name == "parameterReplace")
                        {
                            // now set up the action
                            string portalIdRaw  = rdr.GetAttribute("portalId");
                            int    rulePortalId = -1;
                            if (portalIdRaw != null)
                            {
                                int.TryParse(portalIdRaw, out rulePortalId);
                            }

                            // 807 : if portal specific then import all regardless of portal id specified
                            if (rulePortalId == portalId || rulePortalId == -1 || portalSpecific)
                            {
                                int        actionCount = 0;
                                string     tabIdRaw    = rdr.GetAttribute("tabIds") ?? rdr.GetAttribute("tabId");
                                string     tabNames    = rdr.GetAttribute("tabNames");
                                string     name        = rdr.GetAttribute("name");
                                List <int> tabIds      = XmlHelpers.TabIdsFromAttributes(tabIdRaw, tabNames, portalId,
                                                                                         ref messages);
                                foreach (int tabId in tabIds)
                                {
                                    var action = new ParameterReplaceAction
                                    {
                                        LookFor     = rdr.GetAttribute("lookFor"),
                                        ReplaceWith = rdr.GetAttribute("replaceWith"),
                                        PortalId    = portalId,
                                        Name        = name,
                                        TabId       = tabId,
                                    };
                                    string changeToSiteRootRaw = rdr.GetAttribute("changeToSiteRoot");
                                    bool   changeToSiteRoot;
                                    bool.TryParse(changeToSiteRootRaw, out changeToSiteRoot);
                                    action.ChangeToSiteRoot = changeToSiteRoot;

                                    List <ParameterReplaceAction> tabActionCol;
                                    if (actions.ContainsKey(action.TabId))
                                    {
                                        tabActionCol = actions[action.TabId];
                                    }
                                    else
                                    {
                                        tabActionCol = new List <ParameterReplaceAction>();
                                        actions.Add(action.TabId, tabActionCol);
                                    }

                                    tabActionCol.Add(action);

                                    actionCount++;
                                    messages.Add(name + " replace actions added:" + actionCount.ToString());
                                }
                            }
                        }

                        break;

                    case XmlNodeType.EndElement:
                        break;
                    }
                }

                rdr.Close();
            }
            else
            {
                messages.Add("File not Found: " + fileName);
            }
        }
        public static void LoadFromXmlFile(this Dictionary<int, List<ParameterReplaceAction>> actions, string fileName, int portalId, bool portalSpecific, ref List<string> messages)
        {
            if (messages == null)
            {
                throw new ArgumentNullException("messages");
            }
            messages = new List<string>();
            if (File.Exists(fileName))
            {
                var rdr = new XmlTextReader(fileName);
                while (rdr.Read())
                {
                    switch (rdr.NodeType)
                    {
                        case XmlNodeType.Element:
                            if (rdr.Name == "parameterReplace")
                            {
                                //now set up the action
                                string portalIdRaw = rdr.GetAttribute("portalId");
                                int rulePortalId = -1;
                                if (portalIdRaw != null)
                                {
                                    Int32.TryParse(portalIdRaw, out rulePortalId);
                                }
                                //807 : if portal specific then import all regardless of portal id specified
                                if (rulePortalId == portalId || rulePortalId == -1 || portalSpecific)
                                {
                                    int actionCount = 0;
                                    string tabIdRaw = rdr.GetAttribute("tabIds") ?? rdr.GetAttribute("tabId");
                                    string tabNames = rdr.GetAttribute("tabNames");
                                    string name = rdr.GetAttribute("name");
                                    List<int> tabIds = XmlHelpers.TabIdsFromAttributes(tabIdRaw, tabNames, portalId,
                                                                                       ref messages);
                                    foreach (int tabId in tabIds)
                                    {
                                        var action = new ParameterReplaceAction
                                        {
                                            LookFor = rdr.GetAttribute("lookFor"),
                                            ReplaceWith = rdr.GetAttribute("replaceWith"),
                                            PortalId = portalId,
                                            Name = name,
                                            TabId = tabId
                                        };
                                        string changeToSiteRootRaw = rdr.GetAttribute("changeToSiteRoot");
                                        bool changeToSiteRoot;
                                        bool.TryParse(changeToSiteRootRaw, out changeToSiteRoot);
                                        action.ChangeToSiteRoot = changeToSiteRoot;

                                        List<ParameterReplaceAction> tabActionCol;
                                        if (actions.ContainsKey(action.TabId))
                                        {
                                            tabActionCol = actions[action.TabId];
                                        }
                                        else
                                        {
                                            tabActionCol = new List<ParameterReplaceAction>();
                                            actions.Add(action.TabId, tabActionCol);
                                        }
                                        tabActionCol.Add(action);

                                        actionCount++;
                                        messages.Add(name + " replace actions added:" + actionCount.ToString());
                                    }
                                }
                            }
                            break;

                        case XmlNodeType.EndElement:
                            break;
                    }
                }
                rdr.Close();
            }
            else
            {
                messages.Add("File not Found: " + fileName);
            }
        }