Esempio n. 1
0
        protected override Task SaveAsync(Task toAwait, CancellationToken cancellationToken)
        {
            Task platformHookTask = null;

            if (CurrentInstallationController.IsCurrent(this))
            {
                var configuration = ParseClient.CurrentConfiguration;

                // 'this' is required in order for the extension method to be used.
                this.SetIfDifferent("deviceType", DeviceInfoController.DeviceType);
                this.SetIfDifferent("timeZone", DeviceInfoController.DeviceTimeZone);
                this.SetIfDifferent("localeIdentifier", GetLocaleIdentifier());
                this.SetIfDifferent("parseVersion", GetParseVersion().ToString());
                this.SetIfDifferent("appVersion", configuration.VersionInfo.BuildVersion ?? DeviceInfoController.AppBuildVersion);
                this.SetIfDifferent("appIdentifier", DeviceInfoController.AppIdentifier);
                this.SetIfDifferent("appName", DeviceInfoController.AppName);

                platformHookTask = DeviceInfoController.ExecuteParseInstallationSaveHookAsync(this);
            }

            return(platformHookTask.Safe().OnSuccess(_ =>
            {
                return base.SaveAsync(toAwait, cancellationToken);
            }).Unwrap().OnSuccess(_ =>
            {
                if (CurrentInstallationController.IsCurrent(this))
                {
                    return Task.FromResult(0);
                }
                return CurrentInstallationController.SetAsync(this, cancellationToken);
            }).Unwrap());
        }
        internal override Task SaveAsync(Task toAwait, CancellationToken cancellationToken)
        {
            Task platformHookTask = null;

            if (CurrentInstallationController.IsCurrent(this))
            {
                SetIfDifferent("deviceType", ParseClient.PlatformHooks.DeviceType);
                SetIfDifferent("timeZone", ParseClient.PlatformHooks.DeviceTimeZone);
                SetIfDifferent("localeIdentifier", GetLocaleIdentifier());
                SetIfDifferent("parseVersion", GetParseVersion().ToString());
                SetIfDifferent("appVersion", ParseClient.PlatformHooks.AppBuildVersion);
                SetIfDifferent("appIdentifier", ParseClient.PlatformHooks.AppIdentifier);
                SetIfDifferent("appName", ParseClient.PlatformHooks.AppName);

                // TODO (hallucinogen): this probably should have been a controller.
                platformHookTask = ParseClient.PlatformHooks.ExecuteParseInstallationSaveHookAsync(this);
            }

            return(platformHookTask.Safe().OnSuccess(_ => {
                return base.SaveAsync(toAwait, cancellationToken);
            }).Unwrap()
                   .OnSuccess(_ => {
                if (CurrentInstallationController.IsCurrent(this))
                {
                    return Task.FromResult(0);
                }
                return CurrentInstallationController.SetAsync(this, cancellationToken);
            }).Unwrap());
        }