Esempio n. 1
0
        /// <summary>
        /// Loads any number of external XAP resources from a collection
        /// </summary>
        /// <param name="externalResources">A collection of external resources to load</param>
        /// <param name="raiseEventOnlyAtEnd">Wait until all XAP URIs have loaded before raising the XapLoaded event</param>
        public void BeginLoadXap(ExternalResource[] externalResources, bool raiseEventOnlyAtEnd)
        {
            WebClient client;

            for (int x = 0; x < externalResources.Length; x++)
            {
                client = new WebClient();

                if (raiseEventOnlyAtEnd)
                {
                    if (!(x + 1 < externalResources.Length))
                    {
                        client.OpenReadCompleted += OpenReadCompletedRaiseEvent;
                    }
                    else
                    {
                        client.OpenReadCompleted += OpenReadCompletedNoEvent;
                    }
                }
                else
                {
                    client.OpenReadCompleted += OpenReadCompletedRaiseEvent;
                }

                FetchXap(externalResources[x], client);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the specified resource
        /// </summary>
        /// <param name="resource">The external resource to load</param>
        /// <param name="client">The WebClient object used to fetch the XAP</param>
        private void FetchXap(ExternalResource resource, WebClient client)
        {
            _assemblies.Add(client, Path.GetFileNameWithoutExtension(resource.Path));
            _typeNames.Add(client, resource.Assembly);

            client.OpenReadAsync(new Uri(resource.Path, UriKind.RelativeOrAbsolute));
        }
Esempio n. 3
0
 /// <summary>
 /// Loads any number of external XAP resources from a collection. Raises the XapLoaded after all URIs have been processed
 /// </summary>
 /// <param name="externalResources">A collection of external resources to load</param>
 public void BeginLoadXap(ExternalResource[] externalResources)
 {
     BeginLoadXap(externalResources, true);
 }
Esempio n. 4
0
        /// <summary>
        /// Asyncronously loads the XAP file at the specified URI
        /// </summary>
        /// <param name="resource">URI to the XAP file for which to load</param>
        /// <param name="typeName">Specifies the type name to load</param>
        public void BeginLoadXap(ExternalResource resource)
        {
            WebClient client = new WebClient();

            // Wire up the OpenReadCompleted event handler
            client.OpenReadCompleted += OpenReadCompletedRaiseEvent;

            FetchXap(resource, client);
        }