public void Execute(ActionExecutionContext context) { DeploymentCatalog catalog; if(Catalogs.TryGetValue(uri, out catalog)) Completed(this, new ResultCompletionEventArgs()); else { catalog = new DeploymentCatalog(new Uri("/ClientBin/" + uri, UriKind.RelativeOrAbsolute)); catalog.DownloadCompleted += (s, e) =>{ if(e.Error == null) { Catalogs[uri] = catalog; Catalog.Catalogs.Add(catalog); catalog.Parts .Select(part => ReflectionModelServices.GetPartType(part).Value.Assembly) .Where(assembly => !AssemblySource.Instance.Contains(assembly)) .Apply(x => AssemblySource.Instance.Add(x)); } else Loader.Hide().Execute(context); Completed(this, new ResultCompletionEventArgs { Error = e.Error, WasCancelled = false }); }; catalog.DownloadAsync(); } }
private void OnAppStartup(object sender, StartupEventArgs e) { if (!String.IsNullOrEmpty(ApplicationStartupParameters.Current.Language) && !ApplicationStartupParameters.Current.Language.StartsWith("EN", StringComparison.InvariantCultureIgnoreCase)) { var culture = new CultureInfo(ApplicationStartupParameters.Current.Language); var catalog = new DeploymentCatalog( new Uri(String.Format("{0}.{1}.xap", "Silverlight", culture.TwoLetterISOLanguageName), UriKind.Relative)); CompositionHost.Initialize(catalog); catalog.DownloadCompleted += (s, args) => { if (null == args.Error) { Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; Start(); } else { // cannot download resources for specific language, continue with default language Start(); } }; catalog.DownloadAsync(); } else { Start(); } }
private DeploymentCatalog CreateCatalog(string url) { var catalog = new DeploymentCatalog(url); catalog.DownloadCompleted += (catalog_DownloadCompleted); catalog.DownloadAsync(); return catalog; }
private void Application_Startup(object sender, StartupEventArgs e) { var xapCatalog = new DeploymentCatalog("/ClientBin/ContosoAutomotive.Woodgrove.SL.xap"); xapCatalog.DownloadCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(xapCatalog_DownloadCompleted); xapCatalog.DownloadAsync(); var catalog = new AggregateCatalog(new DeploymentCatalog(), xapCatalog); var container = new CompositionContainer(catalog); this.RootVisual = container.GetExportedValue<CashMaker>(); }
public void AddXap(string uri) { DeploymentCatalog catalog; if (!_catalogs.TryGetValue(uri, out catalog)) { catalog = new DeploymentCatalog(uri); catalog.DownloadAsync(); _catalogs[uri] = catalog; } _aggregateCatalog.Catalogs.Add(catalog); }
public void AddXap(string uri, Action<AsyncCompletedEventArgs> completedAction = null ) { DeploymentCatalog catalog; if (!_catalogs.TryGetValue(uri, out catalog)) { catalog = new DeploymentCatalog(uri); if (completedAction != null) catalog.DownloadCompleted += (s, e) => completedAction(e); else catalog.DownloadCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(catalog_DownloadCompleted); catalog.DownloadAsync(); _catalogs[uri] = catalog; _aggregateCatalog.Catalogs.Add(catalog); } }
/// <summary>Starts the downloading of a XAP package.</summary> /// <param name="packageUri">The URI of the XAP file to download.</param> /// <param name="callback">The callback to invoke when the operation is complete.</param> public void DownloadAsync(Uri packageUri, CallbackAction<IPackage> callback) { // Setup initial conditions. if (packageUri == null) throw new ArgumentNullException("packageUri"); // Start the download. var downloader = new DeploymentCatalog(packageUri); downloader.DownloadCompleted += (s, args) => { if (callback == null) return; var callbackPayload = new Callback<IPackage> { Cancelled = args.Cancelled, Error = args.Error, }; if (!callbackPayload.HasError) callbackPayload.Result = new PackageWrapper(downloader); callback(callbackPayload); }; downloader.DownloadAsync(); }
public void Load(Panel element, string uri, Action<Panel, string> action, Action<Panel, string> undoAction) { if (!string.IsNullOrEmpty(uri)) { if (action != null) { _actions[uri] = action; } if (undoAction != null) { _undoActions[uri] = undoAction; } if (element != null) { _panels[uri] = element; } if (_catalogs.ContainsKey(uri)) { _actions[uri](_panels[uri], uri); return; } var catalog = new DeploymentCatalog(uri); catalog.DownloadCompleted += (s, e) => { if (e.Error != null) { throw e.Error; } _actions[uri](_panels[uri], uri); }; catalog.DownloadAsync(); _catalogs[uri] = catalog; _aggregateCatalog.Catalogs.Add(catalog); } }
private void DownloadModuleFromUri(ModuleInfo moduleInfo, Uri uri) { DeploymentCatalog deploymentCatalog = new DeploymentCatalog(uri); try { // If this module has already been downloaded, fire the completed event. if (this.IsSuccessfullyDownloaded(deploymentCatalog.Uri)) { this.RaiseLoadModuleCompleted(moduleInfo, null); } else { bool needToStartDownload = !this.IsDownloading(uri); // I record downloading for the moduleInfo even if I don't need to start a new download this.RecordDownloading(uri, moduleInfo); if (needToStartDownload) { deploymentCatalog.DownloadProgressChanged += this.DeploymentCatalog_DownloadProgressChanged; deploymentCatalog.DownloadCompleted += this.DeploymentCatalog_DownloadCompleted; deploymentCatalog.DownloadAsync(); } } } catch (Exception) { // if there is an exception between creating the deployment catalog and calling DownloadAsync, // the deployment catalog needs to be disposed. // otherwise, it is added to the compositioncontainer which should handle this. deploymentCatalog.Dispose(); throw; } }
private void DownloadCatalogAsync(Uri uri) { var catalog = new DeploymentCatalog(uri); catalog.DownloadCompleted += catalog_DownloadCompleted; catalog.DownloadAsync(); mainCatalog.Catalogs.Add(catalog); }
public void LoadDeploymentCatalog(string path) { DeploymentCatalog catalog = new DeploymentCatalog(path); catalog.DownloadCompleted += CatalogDownloadCompleted; catalog.DownloadProgressChanged += CatalogDownloadProgressChanged; catalog.DownloadAsync(); Catalog.Catalogs.Add(catalog); }
/// <summary> /// Creates a DeploymentCatalog that targets the specified path. This /// method asynchronously downloads the XAP files in the target folder /// and will update the catalog as it completes. /// </summary> /// <param name="path">The path to download XAP files from</param> /// <returns>the DeploymentCatalog that was created</returns> private static DeploymentCatalog GetDeploymentCatalog(string path) { if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path", "The provided path was empty"); DeploymentCatalog catalog = new DeploymentCatalog(path); catalog.DownloadCompleted += (s, e) => DownloadCompleted(s, e); catalog.DownloadAsync(); return catalog; }
private void addAndDownloadDeploymentCatalogs(IEnumerable<string> xapsDeployedOnServer) { numberOfXapsDeployedOnServer = xapsDeployedOnServer.Count(); deploymentCatalogs.Clear(); foreach (var deployedXap in xapsDeployedOnServer) { //string url = GetBaseUrl() + "ClientBin/" + deployedXap; var xapUri = new Uri(deployedXap, UriKind.Relative); Debug.WriteLine("Dwnloading: " + xapUri); var deploymentCatalog = new DeploymentCatalog(xapUri); deploymentCatalogs.Add(deploymentCatalog); deploymentCatalog.Changed += (o, ee) => OnChanged(ee); deploymentCatalog.Changing += (o, ee) => OnChanging(ee); deploymentCatalog.DownloadCompleted += (o, ee) => OnDownloadCompleted(ee); deploymentCatalog.DownloadAsync(); } }
/// <summary> /// Attempts to load the plug-ins at the specified location. /// </summary> /// <param name="xapLocation"></param> public void BeginAddExternalPackage(Uri xapLocation) { var catalog = new DeploymentCatalog(xapLocation); catalog.DownloadCompleted += new EventHandler<AsyncCompletedEventArgs>(Catalog_DownloadCompleted); catalog.DownloadProgressChanged += new EventHandler<DownloadProgressChangedEventArgs>(Catalog_DownloadProgressChanged); catalog.DownloadAsync(); }
/// <summary /> private void InitializeCatalogs() { // load remote catalogs IDictionary<string, string> args = Application.Current.Host.InitParams; if (args != null && args.ContainsKey("xap")) { string value = args["xap"]; string[] collection = value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string xap in collection) { bool absoluteUri = xap.IndexOf("://", StringComparison.OrdinalIgnoreCase) >= 0; Uri uri = new Uri(xap, absoluteUri ? UriKind.Absolute : UriKind.Relative); DeploymentCatalog dc = new DeploymentCatalog(uri); dc.DownloadCompleted += this.DownloadCompleted; this.pendingDeployments.Add(dc); this.catalogCollection.Catalogs.Add(dc); dc.DownloadAsync(); } } }
public override void Load(Uri targetUri, Uri currentUri) { try { if (!parent._initialized) parent.Initialize(); var saveTargetUri = targetUri; if (!targetUri.IsAbsoluteUri) targetUri = new Uri("MEF:///" + targetUri.OriginalString); string xap = null; if (_uriMap.TryGetValue(saveTargetUri, out xap) && xap != null && !_loadedXaps.Contains(xap)) { var dc = new DeploymentCatalog(xap); dc.DownloadCompleted += (s, e) => { if (e.Error != null) { this.Error(e.Error); return; } _catalog.Catalogs.Add(dc); _loadedXaps.Add(xap); NavigateToPage(targetUri); }; dc.DownloadAsync(); } else NavigateToPage(targetUri); } catch (Exception e) { Error(e); } }