Exemplo n.º 1
0
        public static Dictionary <MarketType, List <TopBannerMenuItemPair> > GetTopBannerMenu()
        {
            String filePath = PathUtilities.CfgPath + "TopBannerMenu.xml";

            if (File.Exists(filePath))
            {
                try {
                    Dictionary <MarketType, List <TopBannerMenuItemPair> > result =
                        new Dictionary <MarketType, List <TopBannerMenuItemPair> >();
                    XmlDocument doc = new XmlDocument();
                    doc.Load(filePath);
                    XmlNode root = doc.SelectSingleNode("Menu");
                    foreach (XmlNode marketNode in root.ChildNodes)
                    {
                        if (marketNode.NodeType == XmlNodeType.Comment)
                        {
                            continue;
                        }
                        if (Enum.IsDefined(typeof(MarketType), marketNode.Attributes["Type"].Value))
                        {
                            MarketType market =
                                (MarketType)Enum.Parse(typeof(MarketType), marketNode.Attributes["Type"].Value);
                            List <TopBannerMenuItemPair> pairs = new List <TopBannerMenuItemPair>();
                            foreach (XmlNode pairNode in marketNode.ChildNodes)
                            {
                                int count = pairNode.ChildNodes.Count;
                                if (count > 0)
                                {
                                    TopBannerMenuItemPair pair = new TopBannerMenuItemPair();
                                    if (count == 1)
                                    {
                                        TopBannerMenuItem item = new TopBannerMenuItem();
                                        item.Caption  = pairNode.FirstChild.Attributes["Caption"].Value ?? String.Empty;
                                        item.Url      = pairNode.FirstChild.Attributes["Url"].Value ?? String.Empty;
                                        item.UrlTitle = pairNode.FirstChild.Attributes["UrlTitle"].Value ?? String.Empty;

                                        pair.Item1 = item;
                                    }
                                    else
                                    {
                                        TopBannerMenuItem item1 = new TopBannerMenuItem();
                                        item1.Caption  = pairNode.FirstChild.Attributes["Caption"].Value ?? String.Empty;
                                        item1.Url      = pairNode.FirstChild.Attributes["Url"].Value ?? String.Empty;
                                        item1.UrlTitle = pairNode.FirstChild.Attributes["UrlTitle"].Value ?? String.Empty;
                                        TopBannerMenuItem item2 = new TopBannerMenuItem();
                                        item2.UrlTitle = pairNode.LastChild.Attributes["UrlTitle"].Value ?? String.Empty;
                                        item2.Url      = pairNode.LastChild.Attributes["Url"].Value ?? String.Empty;
                                        item2.Caption  = pairNode.LastChild.Attributes["Caption"].Value ?? String.Empty;
                                        pair.Item1     = item1;
                                        pair.Item2     = item2;
                                    }
                                    pairs.Add(pair);
                                }
                            }
                            result.Add(market, pairs);
                        }
                    }
                    return(result);
                } catch (Exception e) {
                    LogUtilities.LogMessage(e.Message);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 public TopBannerMenuItemPair()
 {
     Item1 = new TopBannerMenuItem();
     Item2 = new TopBannerMenuItem();
 }