示例#1
0
        internal static async Task <AnimatedVisualFactory?> LoadAsync(
            ImageAssetHandler?imageLoader,
            Uri uri,
            LottieVisualOptions options)
        {
            if (uri is null)
            {
                return(null);
            }

            var absoluteUri = Uris.GetAbsoluteUri(uri);

            if (absoluteUri.Scheme.StartsWith("ms-"))
            {
                // The URI is an application URI. Defer to the StorageFileLoader.
                return(await StorageFileLoader.LoadAsync(imageLoader, absoluteUri, options));
            }
            else
            {
                var loader = new UriLoader(imageLoader);

                return(await Loader.LoadAsync(
                           () => GetJsonStreamAsync(uri),
                           loader,
                           options));
            }
        }
示例#2
0
        static async Task <(string?, Stream?)> GetJsonStreamAsync(Uri uri)
        {
            var absoluteUri = Uris.GetAbsoluteUri(uri);

            if (absoluteUri != null)
            {
                var winrtClient = new Windows.Web.Http.HttpClient();
                var response    = await winrtClient.GetAsync(absoluteUri);

                var result = await response.Content.ReadAsInputStreamAsync();

                return(absoluteUri.LocalPath, result.AsStreamForRead());
            }

            return(null, null);
        }
示例#3
0
            private protected override async Task <(string, Stream)> GetJsonStreamAsync()
            {
                var absoluteUri = Uris.GetAbsoluteUri(_uri);

                if (absoluteUri != null)
                {
                    if (absoluteUri.Scheme.StartsWith("ms-"))
                    {
                        return(await GetStorageFileStreamAsync(await StorageFile.GetFileFromApplicationUriAsync(absoluteUri)));
                    }
                    else
                    {
                        var winrtClient = new Windows.Web.Http.HttpClient();
                        var response    = await winrtClient.GetAsync(absoluteUri);

                        var result = await response.Content.ReadAsInputStreamAsync();

                        return(absoluteUri.LocalPath, result.AsStreamForRead());
                    }
                }

                return(null, null);
            }