Inheritance: IExtensionLite
コード例 #1
0
ファイル: ExtensionsService.cs プロジェクト: steamypassion/X
        public async Task LoadUWPExtension(AppExtension ext)
        {
            // get unique identifier for this extension
            string identifier = ext.AppInfo.AppUserModelId + "!" + ext.Id;

            // load the extension if the package is OK
            if (!(ext.Package.Status.VerifyIsOK()
                  // This is where we'd normally do signature verfication, but don't care right now
                  //&& extension.Package.SignatureKind == PackageSignatureKind.Store
                  ))
            {
                // if this package doesn't meet our requirements
                // ignore it and return
                return;
            }



            // if its already existing then this is an update
            var existingExt = _extensions.Where(e => e.AppExtensionUniqueId == identifier).FirstOrDefault();

            // new extension
            if (existingExt == null)
            {
                try
                {
                    // get extension properties
                    IPropertySet properties = await ext.GetExtensionPropertiesAsync();

                    //IPropertySet properties = null;

                    // create new extension
                    var nExt = new ExtensionLite(ext, properties);

                    // get content and do stuff with it
                    #region content
                    var folder = await ext.GetPublicFolderAsync();

                    if (folder != null)
                    {
                        var file = await folder.GetFileAsync(nExt.Manifest.IconUrl);

                        using (var randomAccessStream = await file.OpenReadAsync())
                        {
                            BitmapImage logo = new BitmapImage();
                            logo.SetSource(randomAccessStream);
                            nExt.Manifest.IconBitmap = logo;
                            nExt.Manifest.IconUrl    = "bitmap";
                        }
                    }
                    //var publicFolder = await ext.Package.InstalledLocation.GetFolderAsync("public");
                    //var file = publicFolder.GetFileAsync("Aws.png");


                    //// get logo
                    //var filestream = await (ext.AppInfo.DisplayInfo.GetLogo(new Windows.Foundation.Size(1, 1))).OpenReadAsync();
                    //BitmapImage logo = new BitmapImage();
                    //logo.SetSource(filestream);
                    #endregion


                    // Add it to extension list
                    _extensions.Add(nExt);

                    // load it
                    //await nExt.Load();
                }
                catch //(Exception ex)
                {
                    //chances are if it fails retrieving properties that the app was added with no properties .. Uninstall the app and reinstall it and hopefully the latest metadata will be there
                }
            }
            // update
            else
            {
                // unload the extension
                existingExt.UnloadUWPExtension();

                // update the extension
                await existingExt.UpdateUWPExtension(ext);
            }
        }
コード例 #2
0
ファイル: ExtensionsService.cs プロジェクト: liquidboy/X
        public async Task LoadUWPExtension(AppExtension ext)
        {
            // get unique identifier for this extension
            string identifier = ext.AppInfo.AppUserModelId + "!" + ext.Id;

            // load the extension if the package is OK
            if (!(ext.Package.Status.VerifyIsOK()
                    // This is where we'd normally do signature verfication, but don't care right now
                    //&& extension.Package.SignatureKind == PackageSignatureKind.Store
                    ))
            {
                // if this package doesn't meet our requirements
                // ignore it and return
                return;
            }



            // if its already existing then this is an update
            var existingExt = _extensions.Where(e => e.AppExtensionUniqueId == identifier).FirstOrDefault();

            // new extension
            if (existingExt == null)
            {
                try
                {
                    // get extension properties
                    IPropertySet properties = await ext.GetExtensionPropertiesAsync();
                    //IPropertySet properties = null;
                    
                    // create new extension
                    var nExt = new ExtensionLite(ext, properties);

                    // get content and do stuff with it
                    #region content
                    var folder = await ext.GetPublicFolderAsync();
                    if (folder != null)
                    {
                        var file = await folder.GetFileAsync(nExt.Manifest.IconUrl);
                        using (var randomAccessStream = await file.OpenReadAsync())
                        {
                            BitmapImage logo = new BitmapImage();
                            logo.SetSource(randomAccessStream);
                            nExt.Manifest.IconBitmap = logo;
                            nExt.Manifest.IconUrl = "bitmap";
                        }
                    }
                    //var publicFolder = await ext.Package.InstalledLocation.GetFolderAsync("public");
                    //var file = publicFolder.GetFileAsync("Aws.png");


                    //// get logo 
                    //var filestream = await (ext.AppInfo.DisplayInfo.GetLogo(new Windows.Foundation.Size(1, 1))).OpenReadAsync();
                    //BitmapImage logo = new BitmapImage();
                    //logo.SetSource(filestream);
                    #endregion


                    // Add it to extension list
                    _extensions.Add(nExt);

                    // load it
                    //await nExt.Load();
                }
                catch //(Exception ex)
                {
                    //chances are if it fails retrieving properties that the app was added with no properties .. Uninstall the app and reinstall it and hopefully the latest metadata will be there
                }
            }
            // update
            else
            {
                // unload the extension
                existingExt.UnloadUWPExtension();

                // update the extension
                await existingExt.UpdateUWPExtension(ext);
            }
        }