Example #1
0
        private void InitFromManifest()
        {
            using (Stream manifestStream = GetFileStreamFromXap("WMAppManifest.xml"))
            {
                KnownApplication persistedAppData = new KnownApplication();

                XPathDocument  document  = new XPathDocument(manifestStream);
                XPathNavigator navigator = document.CreateNavigator().SelectSingleNode("//App");

                Guid = new Guid(navigator.GetAttribute("ProductID", string.Empty));
                Name = navigator.GetAttribute("Title", string.Empty);
                Icon = navigator.SelectSingleNode("//App//IconPath").ToString();

                if (!string.IsNullOrEmpty(Icon))
                {
                    using (Stream iconStream = GetFileStreamFromXap(Icon))
                    {
                        // some weird xaps don't have icons, so GetFileStreamFromXap returns a null
                        if (iconStream != null)
                        {
                            // save the image as the guid to maintain uniqueness
                            PersistedData.SaveBinaryStream(iconStream, Guid.ToString());

                            persistedAppData.Icon = Guid.ToString();
                        }
                    }
                }

                persistedAppData.Name = Name;

                // add this xap to persisted data
                PersistedData.Current.KnownApplication[Guid] = persistedAppData;
            }
        }
        private void InitFromManifest()
        {
            using (Stream manifestStream = GetFileStreamFromXap("WMAppManifest.xml"))
            {
                KnownApplication persistedAppData = new KnownApplication();

                XPathDocument document = new XPathDocument(manifestStream);
                XPathNavigator navigator = document.CreateNavigator().SelectSingleNode("//App");

                Guid = new Guid(navigator.GetAttribute("ProductID", string.Empty));
                Name = navigator.GetAttribute("Title", string.Empty);
                Icon = navigator.SelectSingleNode("//App//IconPath").ToString();

                if (!string.IsNullOrEmpty(Icon))
                {
                    using (Stream iconStream = GetFileStreamFromXap(Icon))
                    {
                        // some weird xaps don't have icons, so GetFileStreamFromXap returns a null
                        if (iconStream != null)
                        {
                            // save the image as the guid to maintain uniqueness
                            PersistedData.SaveBinaryStream(iconStream, Guid.ToString());

                            persistedAppData.Icon = Guid.ToString();
                        }
                    }
                }

                persistedAppData.Name = Name;

                // add this xap to persisted data
                PersistedData.Current.KnownApplication[Guid] = persistedAppData;
            }
        }