Error() private méthode

private Error ( string id, string category, string targetObjectValue, string messageText ) : bool
id string
category string
targetObjectValue string
messageText string
Résultat bool
        internal static void RemovePackageSource(string name, Request request)
        {
            IDictionary<string, PackageSource> packageSources = GetPackageSources(request);

            if (!packageSources.ContainsKey(name))
            {
                request.Error(ErrorCategory.ResourceUnavailable.ToString(), name, Strings.PackageSourceNotFound, name);
                return;
            }

            packageSources.Remove(name);
            SavePackageSources(packageSources, request);
        }
        internal static void AddPackageSource(string name, string location, bool trusted, Request request)
        {
            IDictionary<string, PackageSource> packageSources = GetPackageSources(request);

            if (packageSources.ContainsKey(name))
            {
                request.Error(ErrorCategory.ResourceExists.ToString(), name, Strings.PackageSourceExists, name);
                return;
            }

            packageSources.Add(name, new PackageSource() { Name = name, Location = location, Trusted = trusted, IsRegistered = true, IsValidated = true });
            SavePackageSources(packageSources, request);
        }
        /// <summary>
        /// Uninstalls a package 
        /// </summary>
        /// <param name="fastPackageReference"></param>
        /// <param name="request">An object passed in from the CORE that contains functions that can be used to interact with the CORE and HOST</param>
        public void UninstallPackage(string fastPackageReference, Request request)
        {
            request.Debug("Calling '{0}::UninstallPackage' '{1}'", PackageProviderName, fastPackageReference);

            string source;
            string id;
            string version;
            if (!fastPackageReference.TryParseFastPath(out source, out id, out version))
            {
                request.Error(ErrorCategory.InvalidArgument.ToString(), fastPackageReference, Strings.InvalidFastPath, fastPackageReference);
            }

            // TODO: uninstall
        }
        /// <summary>
        /// Installs a given package.
        /// </summary>
        /// <param name="fastPackageReference">A provider supplied identifier that specifies an exact package</param>
        /// <param name="request">An object passed in from the CORE that contains functions that can be used to interact with the CORE and HOST</param>
        public void InstallPackage(string fastPackageReference, Request request)
        {
            request.Debug("Calling '{0}::InstallPackage' '{1}'", PackageProviderName, fastPackageReference);

            string source; //ignore
            string id; //url or file path
            string version;
            if (!fastPackageReference.TryParseFastPath(out source, out id, out version))
            {
                request.Error("", ErrorCategory.InvalidArgument.ToString(), fastPackageReference, Strings.InvalidFastPath);
            }

            var error = DscInvoker.SetLCMToDisabled();
            if(error != null)
            {
                request.Error("", ErrorCategory.InvalidOperation.ToString(), fastPackageReference, error.ErrorDetails.Message);
            }

            request.Debug("set the local LCM to disabled mode");

            request.Debug("try getting silent install option");

            var option = FindAppNameSilentArgs(id);

            if (option != null)
            {
                error = DscInvoker.InvokeDscPackegeResource(option.Item1, option.Item2, id);
                if (error != null)
                {
                    request.Error("", ErrorCategory.InvalidOperation.ToString(), fastPackageReference, error.ErrorDetails.Message);
                }
            }
            else
            {
                // Prepare the process to run
                ProcessStartInfo start = new ProcessStartInfo();
                // Enter the executable to run, including the complete path
                start.FileName = id;
                // Do you want to show a console window?
                start.WindowStyle = ProcessWindowStyle.Normal;
                //start.CreateNoWindow = true;

                // Run the external process & wait for it to finish
                using (Process proc = Process.Start(start))
                {
                    proc.WaitForExit();

                    // Retrieve the app's exit code
                    var exitCode = proc.ExitCode;
                    if(exitCode != 0)
                    {
                        request.Error("", ErrorCategory.InvalidOperation.ToString(), fastPackageReference, string.Format("running installation package {0} failed, error detail is {1}",id, proc.StandardError.ReadToEnd()));
                    }
                }
            }
        }