1

I have a silverlight application where I download xaps using MEF. I would like to put a authorization token in the header of the call so that not anyone will be able to reach the xaps. Something like this:

catalog = new DeploymentCatalog(_uri);
catalog.AddHeader(_header);
catalog.DownloadAsync();

Only problem is that there is no AddHeader method.

user438236
  • 357
  • 3
  • 9

1 Answers1

1

DeploymentCatalog uses WebClient under the hood, but doesn't seem to expose it in any way.

There's a copy of the source here (couldn't find it on CodePlex for some reason). The URI is used by the WebClient to perform an asynchronous download. On completion, the response is used to create a collection of assemblies using Package.LoadPackagedAssemblies. Composition is performed using those assemblies.

Some of the relevant code:

//the download
this.WebClient.OpenReadCompleted += new OpenReadCompletedEventHandler(HandleOpenReadCompleted);
this.WebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(HandleDownloadProgressChanged);
this.WebClient.OpenReadAsync(Uri, this);

//composition on completion of async download
var assemblies = Package.LoadPackagedAssemblies(e.Result);
this.DiscoverParts(assemblies);

You could create a custom catalog that does the same thing but provides an AddHeader method, or exposes the WebClient, or whatever.

Matt
  • 548
  • 9
  • 24