public async Task Init() { _catalog = AppExtensionCatalog.Open(Consts.ExtensionContract); // set up extension management events _catalog.PackageInstalled += _catalog_PackageInstalled; _catalog.PackageUpdated += _catalog_PackageUpdated; _catalog.PackageUninstalling += _catalog_PackageUninstalling; _catalog.PackageUpdating += _catalog_PackageUpdating; _catalog.PackageStatusChanged += _catalog_PackageStatusChanged; // Scan all extensions await FindAllExtensions(); }
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); } } }
public MainPage() { this.InitializeComponent(); _catalog = AppExtensionCatalog.Open("Atmosphere"); _catalog.PackageInstalled += _catalog_PackageInstalled; InstallPackageContent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; this.Loaded += MainPage_Loaded; this.KeyDown += MainPage_KeyDown; _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(2); _timer.Tick += _timer_Tick; _timer.Start(); #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 onRotationChangedHandler = new TypedEventHandler <DisplayInformation, object>((di, o) => { OnRotate(di); }); ExtendedSplashImage.RenderTransformOrigin = new Point(0.5, 0.5); var displayInfo = DisplayInformation.GetForCurrentView(); displayInfo.OrientationChanged += onRotationChangedHandler; OnRotate(displayInfo); SetupLocationService(); #endif }
public async Task InitAsync() { this.catalog = AppExtensionCatalog.Open(this.pluginName); // set up extension management events this.catalog.PackageInstalled += this.Catalog_PackageInstalled; this.catalog.PackageUpdated += this.Catalog_PackageUpdated; this.catalog.PackageUninstalling += this.Catalog_PackageUninstalling; this.catalog.PackageUpdating += this.Catalog_PackageUpdating; this.catalog.PackageStatusChanged += this.Catalog_PackageStatusChanged; // Scan all extensions await FindAllExtensionsAsync(); }
public void InitializeCatalog() { _catalog = AppExtensionCatalog.Open(_contract); AppSettings.Clear(); if (_dispatcher != null) { throw new Exception("Extension Manager for " + this._contract + " is already initialized."); } // thread that initializes the extension manager has the dispatcher _dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher; // set up extension management events _catalog.PackageInstalled += Catalog_PackageInstalled; _catalog.PackageUninstalling += Catalog_PackageUninstalling; _catalog.PackageUpdating += Catalog_PackageUpdating; _catalog.PackageUpdated += Catalog_PackageUpdated; _catalog.PackageStatusChanged += Catalog_PackageStatusChanged; }
public ExtensionsProvider(string contract, IServiceFactory factory, IFilePicker picker) { var catalog = AppExtensionCatalog.Open(contract); var source = new SourceCache <AppExtension, string>(a => a.Id); Connect = ReactiveCommand.CreateFromTask(async() => { var initial = await catalog.FindAllAsync(); source.Edit(x => { x.Clear(); var findAllAsync = initial; x.AddOrUpdate(findAllAsync); refreshers.Dispose(); DisposableMixins.DisposeWith(Observable .FromEventPattern <AppExtensionPackageInstalledEventArgs>(catalog, "PackageInstalled") .Subscribe(args => x.AddOrUpdate(args.EventArgs.Extensions)), refreshers); DisposableMixins.DisposeWith(Observable .FromEventPattern <AppExtensionPackageUninstallingEventArgs>(catalog, "PackageUninstalling") .Subscribe(args => { }), refreshers); }); return(Unit.Default); }); Func <Task <byte[]> > GetLogo(AppExtension appExtension) { return(async() => { try { var open = await appExtension.AppInfo.DisplayInfo.GetLogo(new Size(1, 1)).OpenReadAsync(); var stream = open.AsStreamForRead(); return await StreamMixin.ReadBytes(stream); } catch (Exception e) { return null; } }); } Func <Task <IDictionaryBasedService> > GetService(AppExtension appExtension) { return(async() => { var connInfo = await appExtension.GetConnectionInfo(); return factory.Create(connInfo.Item1, connInfo.Item2); }); } ObservableChangeset = source .Connect() .Transform(ext => new ImportViewModel(ext.DisplayName, ext.Description, GetLogo(ext), GetService(ext), picker)); DisposableMixins.DisposeWith(ObservableChangeset .Bind(out extensions) .Subscribe(), disposables); DisposableMixins.DisposeWith(Connect.Execute() .Subscribe(), disposables); }