ZeroInstall.DesktopIntegration.ViewModel.IntegrationState.ApplyChanges C# (CSharp) Method

ApplyChanges() public method

Applies any changes made to the View-Model to the underlying system.
The user canceled the task. One or more of the new s would cause a conflict with the existing s in . One of the s or s is invalid. A problem occured while downloading additional data (such as icons). A problem occurs while writing to the filesystem or registry. Write access to the filesystem or registry is not permitted.
public ApplyChanges ( ) : void
return void
        public void ApplyChanges()
        {
            var toAdd = new List<AccessPoints.AccessPoint>();
            var toRemove = new List<AccessPoints.AccessPoint>();
            (CapabilitiyRegistration ? toAdd : toRemove).Add(new AccessPoints.CapabilityRegistration());
            CollectCommandAccessPointChanges(toAdd, toRemove);
            CollectDefaultAccessPointChanges(toAdd, toRemove);

            if (toRemove.Any()) _integrationManager.RemoveAccessPoints(AppEntry, toRemove);
            if (toAdd.Any()) _integrationManager.AddAccessPoints(AppEntry, Feed, toAdd);
        }
    }

Usage Example

Esempio n. 1
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null) throw new ArgumentNullException(nameof(interfaceUri));
            if (integrationManager == null) throw new ArgumentNullException(nameof(integrationManager));
            #endregion

            if (RemoveOnly())
            {
                RemoveOnly(integrationManager, interfaceUri);
                return ExitCode.OK;
            }

            CheckInstallBase();

            var appEntry = GetAppEntry(integrationManager, ref interfaceUri);
            var feed = FeedManager[interfaceUri];

            if (NoSpecifiedIntegrations())
            {
                var state = new IntegrationState(integrationManager, appEntry, feed);
                Retry:
                Handler.ShowIntegrateApp(state);
                try
                {
                    state.ApplyChanges();
                }
                    #region Error handling
                catch (ConflictException ex)
                {
                    if (Handler.Ask(
                        Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                        defaultAnswer: false, alternateMessage: ex.Message))
                        goto Retry;
                }
                catch (InvalidDataException ex)
                {
                    if (Handler.Ask(
                        Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                        defaultAnswer: false, alternateMessage: ex.Message))
                        goto Retry;
                }
                #endregion

                return ExitCode.OK;
            }

            RemoveAndAdd(integrationManager, feed, appEntry);
            return ExitCode.OK;
        }