Ejemplo n.º 1
0
        private async void InstallPackageContent()
        {
            foreach (var extension in await _catalog.FindAllAsync())
            {
                var folder = await extension.GetPublicFolderAsync();

                var files = await folder.GetFilesAsync();

                _soundFiles = files.Where(i => i.Name.EndsWith(".mp3"));
            }
        }
Ejemplo n.º 2
0
        public async Task PopulateAllUWPExtensions()
        {
            if (_dispatcher == null)
            {
                throw new Exception("Extension Manager for " + this._contract + " is not initialized.");
            }

            IReadOnlyList <AppExtension> extensions = await _catalog.FindAllAsync();

            foreach (AppExtension ext in extensions)
            {
                await LoadUWPExtension(ext);
            }
        }
Ejemplo n.º 3
0
        public async Task FindAllExtensions()
        {
            // load all the extensions currently installed
            IReadOnlyList <AppExtension> extensions = await _catalog.FindAllAsync();

            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async() =>
            {
                foreach (AppExtension ext in extensions)
                {
                    // load this extension
                    await LoadExtension(ext);
                }
                ExtensionList.ToList().ForEach(async(x) => { await x.Load(); });
            });
        }
Ejemplo n.º 4
0
        public async Task <IReadOnlyList <IAppExtension> > FindAllAsync()
        {
            var extensions = await _catalog.FindAllAsync();

            return(extensions.Select(e => new AppExtensionWrapper(e)).ToList());
        }
Ejemplo n.º 5
0
        public async Task <Dictionary <string, object> > InvokeExtension(string extensionId, Dictionary <string, object> parameters)
        {
            Employee employee = new Employee();
            //"com.extensions.yamoney.teststand"
            AppExtensionCatalog catalog = AppExtensionCatalog.Open(extensionId);
            var extensions = new System.Collections.Generic.List <AppExtension>(await catalog.FindAllAsync());

            var employeeService   = extensions[0];
            var packageFamilyName = employeeService.Package.Id.FamilyName;

            IPropertySet properties = await employeeService.GetExtensionPropertiesAsync();

            PropertySet serviceProperty = (PropertySet)properties["Service"];
            var         serviceName     = serviceProperty["#text"].ToString();

            AppServiceConnection connection = new AppServiceConnection
            {
                AppServiceName    = serviceName,
                PackageFamilyName = packageFamilyName
            }; // Параметры подключения


            var message = new ValueSet(); // Параметры для передачи

            foreach (var kv in parameters)
            {
                message.Add(kv);
            }

            var status = await connection.OpenAsync(); // Открываем подключение

            using (connection)
            {
                if (status != AppServiceConnectionStatus.Success) // Проверяем статус
                {
                    return(null);
                }

                var response = await connection.SendMessageAsync(message); // Отправляем сообщение и ждем ответа

                if (response.Status == AppServiceResponseStatus.Success)
                {
                    return(response.Message.ToDictionary(kv => kv.Key, kv => kv.Value));
                }
                else
                {
                    return(null);
                }
            }
        }