Exemplo n.º 1
0
        /// <summary>
        /// Returns an already completed task with a given result.
        /// </summary>
        /// <returns>The completed task.</returns>
        internal static AppCenterTask <TResult> FromCompleted(TResult result)
        {
            var task = new AppCenterTask <TResult>();

            task.SetResult(result);
            return(task);
        }
 public static void CacheStorageSize(long storageSize)
 {
     if (_storageSizeTask != null)
     {
         _storageSizeTask.SetResult(storageSize);
     }
 }
 public static void CacheLogUrl(string logUrl)
 {
     if (_logUrlTask != null)
     {
         _logUrlTask.SetResult(logUrl);
     }
 }
        /// <summary>
        /// Get the unique installation identifier for this application installation on this device.
        /// </summary>
        /// <remarks>
        /// The identifier is lost if clearing application data or uninstalling application.
        /// </remarks>
        public static AppCenterTask <Guid?> GetInstallIdAsync()
        {
            var stringTask = AppCenterInternal.GetInstallIdAsync();
            var guidTask   = new AppCenterTask <Guid?>();

            stringTask.ContinueWith(t =>
            {
                var installId = !string.IsNullOrEmpty(t.Result) ? new Guid(t.Result) : (Guid?)null;
                guidTask.SetResult(installId);
            });
            return(guidTask);
        }
        // Gets the first instance of an app secret corresponding to the given platform name, or returns the string
        // as-is if no identifier can be found.
        public static string ParseAndSaveSecretForPlatform(string secrets)
        {
            var platformIdentifier = GetPlatformIdentifier();

            if (platformIdentifier == null)
            {
                // Return as is for unsupported platform.
                return(secrets);
            }
            if (secrets == null)
            {
                // If "secrets" is null, return that and let the error be dealt
                // with downstream.
                return(secrets);
            }

            // If there are no equals signs, then there are no named identifiers
            if (!secrets.Contains("="))
            {
                return(secrets);
            }

            var platformIndicator = platformIdentifier + "=";
            var secretIdx         = secrets.IndexOf(platformIndicator, StringComparison.Ordinal);

            if (secretIdx == -1)
            {
                // If the platform indicator can't be found, return the original
                // string and let the error be dealt with downstream.
                return(secrets);
            }
            secretIdx += platformIndicator.Length;
            var platformSecret = string.Empty;

            while (secretIdx < secrets.Length)
            {
                var nextChar = secrets[secretIdx++];
                if (nextChar == ';')
                {
                    break;
                }

                platformSecret += nextChar;
            }
            if (_secretTask != null)
            {
                _secretTask.SetResult(platformSecret);
            }
            return(platformSecret);
        }