public RssFeed GetFeed(string url)
        {
            var xmlLoader = new XmlLoader();
            var feed      = xmlLoader.GetXml <RssFeed>(url);

            return(feed);
        }
        public RssFeed GetAtomFeed(string url)
        {
            var xmlLoader = new XmlLoader();
            var atomFeed  = xmlLoader.GetXml <AtomFeed>(url);

            var rssFeed = new RssFeed(atomFeed);

            return(rssFeed);
        }
Example #3
0
        /// <summary>
        /// 通过xml修改窗口的公共样式
        /// </summary>
        /// <returns>是否修改成功</returns>
        /// <author>宋佳恒</author>
        /// <date>2017-03-30</date>

        protected bool Decorate(string xmlName)
        {
            //获取当前窗口类的类型
            Type realType = this.GetType();

            try
            {
                //读取xml
                XmlDocument xmlDoc = XmlLoader.GetXml(xmlName);
                //遍历窗口类中所有的字段
                foreach (FieldInfo field in realType.GetFields(System.Reflection.BindingFlags.NonPublic
                                                               | System.Reflection.BindingFlags.Instance
                                                               | System.Reflection.BindingFlags.IgnoreCase))
                {
                    //根据字段名获取控件
                    Control obj = this.Controls[field.Name];
                    //未获取到控件则continue
                    if (null == obj)
                    {
                        continue;
                    }

                    string fieldType      = field.FieldType.ToString();                          //字段的完整类路径,例如:System.Windows.Forms.Button
                    string fieldShortType = fieldType.Substring(fieldType.LastIndexOf(".") + 1); //字段的类名,例如:Button

                    XmlNode node = xmlDoc.SelectSingleNode("/Form/" + fieldShortType);           //根据字段类名获取xml中的node,例如<Button width="100"></Button>
                    if (node != null)
                    {
                        XmlElement xmlElement = (XmlElement)node;
                        //遍历xmlElement中的属性
                        foreach (XmlAttribute attr in xmlElement.Attributes)
                        {
                            try
                            {
                                //根据属性名获取控件的属性特性
                                PropertyInfo pro = obj.GetType().GetProperty(attr.Name);
                                //根据属性特性获取属性的实际类型
                                Type t = pro.PropertyType;
                                //修改控件的属性值
                                pro.SetValue(obj, ConvertValueType(attr.Value, t), null);
                            }
                            catch (InvalidCastException ex)
                            {
                                Console.WriteLine(attr);
                                Console.WriteLine(ex.Message);
                            }
                        }
                    }
                }
            }
            catch (XmlException ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
            return(true);
        }
        public HighlightsCollection GetHighlights()
        {
            HighlightsCollection highlightsCollection = null;

            var xmlLoader = new XmlLoader();
            highlightsCollection = xmlLoader.GetXml<HighlightsCollection>(HighlightsXmlUrl);

            return highlightsCollection;
        }
        public GameSummary GetGameSummary()
        {
            GameSummary gameSummary = null;

            var xmlLoader = new XmlLoader();
            gameSummary = xmlLoader.GetXml<GameSummary>(GameSummaryXmlUrl);

            return gameSummary;
        }
        public GameCenter GetGameCenter()
        {
            GameCenter gameCenter = null;

            var xmlLoader = new XmlLoader();
            gameCenter = xmlLoader.GetXml<GameCenter>(GameCenterXmlUrl);

            return gameCenter;
        }
        public GameSummaryCollection GetSummaryCollection(DateTime date)
        {
            var url = BuildUrl(date);
            GameSummaryCollection gameSummaryCollection = null;

            var xmlLoader = new XmlLoader();
            gameSummaryCollection = xmlLoader.GetXml<GameSummaryCollection>(url);

            return gameSummaryCollection;
        }
Example #8
0
        public GameSummary GetGameSummary()
        {
            GameSummary gameSummary = null;

            var xmlLoader = new XmlLoader();

            gameSummary = xmlLoader.GetXml <GameSummary>(GameSummaryXmlUrl);

            return(gameSummary);
        }
Example #9
0
        public GameCenter GetGameCenter()
        {
            GameCenter gameCenter = null;

            var xmlLoader = new XmlLoader();

            gameCenter = xmlLoader.GetXml <GameCenter>(GameCenterXmlUrl);

            return(gameCenter);
        }
Example #10
0
        public HighlightsCollection GetHighlights()
        {
            HighlightsCollection highlightsCollection = null;

            var xmlLoader = new XmlLoader();

            highlightsCollection = xmlLoader.GetXml <HighlightsCollection>(HighlightsXmlUrl);

            return(highlightsCollection);
        }
        public GameSummaryCollection GetSummaryCollection(DateTime date)
        {
            var url = BuildUrl(date);
            GameSummaryCollection gameSummaryCollection = null;

            var xmlLoader = new XmlLoader();

            gameSummaryCollection = xmlLoader.GetXml <GameSummaryCollection>(url);

            return(gameSummaryCollection);
        }