private static void RunRegisterCompositionListener(CompositionCommandInfo info,
                                                           XmlProcessingContext xmlProcessingContext)
        {
            if (!(info is RegisterCompositionListenerInfo registerCompositionListenerInfo))
            {
                throw new ArgumentException("Invalid runner input type: error in static setup.");
            }

            var listener = XmlValueParser.ParseValue(registerCompositionListenerInfo.XElements,
                                                     registerCompositionListenerInfo.XAttributes,
                                                     xmlProcessingContext);

            if (listener == null)
            {
                xmlProcessingContext.ReportError("Provided value is null for registering composition listeners.");
                return;
            }

            if (!(listener is ICompositionListener compositionListener))
            {
                xmlProcessingContext.ReportError(
                    "Registering composition listeners are only allowed for ICompositionListener implementations. Provided type: " +
                    listener.GetType().FullName);
                return;
            }

            xmlProcessingContext.ComponentContext.RegisterCompositionListener(registerCompositionListenerInfo.Name,
                                                                              compositionListener);
        }
        private static Lazy <object> CreateLazyXmlValue(XmlElement[] xElements, XmlAttribute[] xAttributes,
                                                        XmlProcessingContext xmlProcessingContext)
        {
            return(new Lazy <object>(delegate
            {
                object result = XmlValueParser.ParseValue(xElements, xAttributes, xmlProcessingContext);
                xmlProcessingContext.ThrowIfErrors();

                xElements = null;
                xAttributes = null;
                xmlProcessingContext = null;

                return result;
            }));
        }
Exemple #3
0
        public void GetList_Completed(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    throw new Exception(e.Error.Message);
                }
                var o = XDocument.Parse(e.Result);

                if (o.Root.Element("status_code").Value == "200")
                {
                    total = XmlValueParser.ParseInteger(o.Root.Element("album").Element("total"));

                    foreach (var v in o.Descendants("item"))
                    {
                        if (v.Element("album_id") != null)
                        {
                            AlbumItem item = new AlbumItem();
                            item.album_id    = v.Element("album_id").Value;
                            item.album_title = v.Element("album_title").Value;

                            List.Add(item);
                        }
                    }
                }
                else
                {
                    throw new Exception("code is " + o.Root.Element("status_code").Value);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("AlbumPage.xaml.cs : GetList_Completed ; " + ex.Message);
                MessageBox.Show("เกิดเหตุขัดข้อง กรุณาลองใหม่อีกครั้งภายหลัง");
                this.NavigationService.GoBack();
                NavigationService.Navigate(new Uri("/MainPage.xaml?Refresh=true", UriKind.Relative));
            }

            SetLoadingEpisodeListVisibility(false);
        }
Exemple #4
0
        private void GetList_Completed(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                {
                    throw new Exception(e.Error.Message);
                }
                //----------
                XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
                if (xdoc.Root == null)
                {
                    throw new Exception("Root is null");
                }

                if (xdoc.Root.Element("status_code") == null)
                {
                    throw new Exception("status_code is null");
                }

                if (xdoc.Root.Element("data") == null)
                {
                    throw new Exception("data is null");
                }

                if (xdoc.Root.Element("data").Element("contents") == null)
                {
                    throw new Exception("data/contents is null");
                }
                //----------
                if (xdoc.Root.Element("status_code").Value != "200")
                {
                    throw new Exception("code is " + xdoc.Root.Element("status_code").Value + " ~ " + xdoc.Root.Element("status_txt").Value);
                }
                else
                {
                    string tag = "";

                    if ((sender as WebClient).Headers["id"] == "liveTv")
                    {
                        tag = "entry";// item
                        AddChannelAllList.Clear();
                    }
                    //-----
                    var list = xdoc.Root.Element("data").Element("contents").Elements(tag);
                    foreach (var item in list)
                    {
                        MediaHighlightItem tmp_item = new MediaHighlightItem();

                        //parse
                        tmp_item.content_id    = XmlValueParser.ParseInteger(item.Element("content_id"));
                        tmp_item.channel_name  = XmlValueParser.ParseString(item.Element("channel_name"));
                        tmp_item.thumbnail     = XmlValueParser.ParseString(item.Element("thumbnail"));
                        tmp_item.thumbnail_App = XmlValueParser.ParseString(item.Element("thumbnail_app"));
                        tmp_item.category      = XmlValueParser.ParseString(item.Element("category"));
                        tmp_item.rating        = XmlValueParser.ParseString(item.Element("rating"));
                        tmp_item.view          = XmlValueParser.ParseString(item.Element("view"));
                        tmp_item.Share_url     = XmlValueParser.ParseString(item.Element("share_url"));

                        if ((sender as WebClient).Headers["id"] == "liveTv")
                        {
                            selected = false;

                            for (int i = 0; i < (Application.Current as App).FavoriteIndexList.Count; i++)
                            {
                                if ((Application.Current as App).FavoriteIndexList[i].content_id.Equals(tmp_item.content_id))
                                {
                                    selected = true;
                                }
                            }

                            if (selected)
                            {
                                tmp_item.PicSelected = "Assets/btn_select_active.png";
                                SelectCount++;
                            }
                            else
                            {
                                tmp_item.PicSelected = "Assets/btn_select.png";
                            }
                            AddChannelAllList.Add(tmp_item);
                        }
                    }
                    PanoramaItem.Header = "เพิ่มช่องโปรด (" + SelectCount + "/20)";
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("HomePage : MediaHighlightItemList_DownloadStringCompleted ; " + ex.Message);
            }
            HideProgressIndicator();
        }