Exemplo n.º 1
0
        /// <summary>
        ///     Download information to repair the current installation
        /// </summary>
        /// <returns>Return the information required by the downloader to scan the current files and find differences</returns>
        public async Task <UpdatePackageFilebase> RepairAsync()
        {
            var version = VersionProvider.GetVersion();

            HttpClientSetHeaders(version);

            var uri = new Uri($"packages/{Uri.EscapeDataString(version.ToString())}/files", UriKind.Relative);

            var platforms = PlatformProvider?.GetEncodedPlatforms();

            if (platforms != null)
            {
                uri = uri.AddQueryParameters("platforms", platforms.Value.ToString());
            }

            var response = await _httpClient.Value.GetAsync(uri);

            if (!response.IsSuccessStatusCode)
            {
                throw await UpdateSystemResponseExtensions.GetResponseException(response, this);
            }

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

            var jwtResponse =
                JsonConvert.DeserializeObject <JwtResponse <List <SignedFileInformation> > >(result,
                                                                                             _jsonSerializerSettings);

            HttpClientSetJwt(jwtResponse);
            return(new UpdatePackageFilebase(jwtResponse.Result, this, version));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Search for new update packages with the given options
        /// </summary>
        /// <returns>Return the result of the update search</returns>
        public async Task <UpdatePackageSearchResult> SearchForNewUpdatePackagesAsync()
        {
            var versionFilter = VersionFilter?.GetSupportedPrereleases();

            if (versionFilter?.Length > 10)
            {
                throw new ArgumentException("A maximum of 10 version filters is allowed.");
            }

            var httpClient = _httpClient.Value;
            var version    = VersionProvider.GetVersion();

            HttpClientSetHeaders(version);

            try
            {
                var uri = new Uri($"packages/{Uri.EscapeDataString(version.ToString())}/check", UriKind.Relative);

                var platforms = PlatformProvider?.GetEncodedPlatforms();
                if (platforms != null)
                {
                    uri = uri.AddQueryParameters("platforms", platforms.Value.ToString());
                }

                if (versionFilter?.Length > 0)
                {
                    uri = uri.AddQueryParameters("versionFilter",
                                                 Uri.EscapeDataString(JsonConvert.SerializeObject(versionFilter)));
                }

                var response = await httpClient.GetAsync(uri);

                if (!response.IsSuccessStatusCode)
                {
                    throw await UpdateSystemResponseExtensions.GetResponseException(response, this);
                }

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

                var jwtResponse =
                    JsonConvert.DeserializeObject <JwtResponse <UpdatePackageSearchResult> >(result,
                                                                                             _jsonSerializerSettings);

                HttpClientSetJwt(jwtResponse);
                var searchResult = jwtResponse.Result;
                searchResult.Initialize(this);

                if (!searchResult.IsUpdateAvailable)
                {
                    Settings?.NoUpdatesFoundCleanup(ProjectId);
                }

                return(searchResult);
            }
            finally
            {
                httpClient.DefaultRequestHeaders.AcceptLanguage.Clear();
            }
        }
Exemplo n.º 3
0
        private void AddModel(IDictionary <uint, CameraData> cameras, IDictionary <string, PlatformData> platforms, IDictionary <string, TreePlatformData> treeCameras,
                              string key, ListPlatformData list, string productName)
        {
            var platform = PlatformProvider.GetPlatform(key, platforms, productName);
            var tree     = PlatformProvider.GetTree(key, treeCameras, productName);
            var modelId  = Convert.ToUInt32(platform.ModelId, 16);
            var camera   = GetOrAddCamera(modelId, key, list, tree, cameras, productName);
            var model    = ModelProvider.GetModel(key, platform.Names, list, tree, productName);

            camera.Models = camera.Models.Concat(new[] { model }).ToArray();
        }
Exemplo n.º 4
0
 private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     platformProvider = FindObjectOfType<PlatformProvider>();
 }
Exemplo n.º 5
0
 private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     // If anyway there is a new PlayerControllerb on each scene 
     // remove Awake and OnSceneLoaded and simply set the reference in the Inspector.
     platformProvider = FindObjectOfType<PlatformProvider>();
 }