Beispiel #1
0
 private bool PromptForOverwrite(string target)
 {
     return(Stdio.Prompt(String.Format("Export target {0} is not empty, overwrite (Yes/No)? ", target)));
 }
Beispiel #2
0
 private bool PromptForDelete(string key)
 {
     return(Stdio.Prompt(String.Format("Delete the value {0} (Yes/No)? ", key)));
 }
Beispiel #3
0
        public override void Execute()
        {
            PrintLineVerbose("open");
            OpenApplicationData();

            PrintLineVerbose("execute");
            System.Diagnostics.Debug.Assert(this.locality == Locality.Local || this.locality == Locality.Roaming);
            var settings = (this.locality == Locality.Local) ? appdata.LocalSettings : appdata.RoamingSettings;

            PrintLineVerbose("container");
            if (this.valueKey.IsEmpty() && !this.deleteAllValuesInContainer)
            {
                System.Diagnostics.Debug.Assert(!this.path.IsEmpty());
                if (!this.force && !Stdio.Prompt(String.Format("Permanently delete the container {0} (Yes/No)? ", AppDataExtensions.BuildPath(settings, this.path))))
                {
                    FatalError("The operation was canceled by the user.");
                }
                try
                {
                    settings.DeleteContainer(this.path);
                }
                catch (Exception ex)
                {
                    if (ex.HResult == Win32Errors.ERROR_OBJECT_NOT_FOUND)
                    {
                        FatalError("Container path not found", this.path);
                    }
                    else
                    {
                        FatalError(ex.ToString());
                    }
                    return;
                }
            }
            else
            {
                ApplicationDataContainer container;
                if (this.path.IsEmpty())
                {
                    container = settings;
                }
                else
                {
                    try
                    {
                        container = settings.CreateContainer(this.path, ApplicationDataCreateDisposition.Always);
                    }
                    catch (Exception ex)
                    {
                        if (ex.HResult == Win32Errors.ERROR_OBJECT_NOT_FOUND)
                        {
                            FatalError("Container path not found", this.path);
                        }
                        else
                        {
                            FatalError(ex.ToString());
                        }
                        return;
                    }
                }

                PrintLineVerbose("delete");
                if (this.deleteAllValuesInContainer)
                {
                    DeleteValues(container, AppDataExtensions.BuildPath(container, this.path));
                }
                else
                {
                    DeleteValue(container, this.valueKey);
                }
            }

            PrintLine("The operation completed successfully.");
        }
Beispiel #4
0
 private bool PromptForDelete(Windows.Foundation.Collections.IPropertySet values, string containerPath)
 {
     return(Stdio.Prompt(String.Format("Delete all {0} {1} in the container {2} (Yes/No)? ", values.Count, "value".Plural(values.Count), containerPath)));
 }