コード例 #1
0
 private void NamespaceMerge(object sender, MergingEventArgs e)
 {
     _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                            "MergeHelpNamespace"), e.Name));
 }
コード例 #2
0
        public int Run(RegistrationOptions options, IRegistrationHelper helper)
        {
            if (options == null || helper == null)
            {
                return(-1);
            }

            _regOptions = options;
            _regHelper  = helper;

            RegistrationHelper.Instance.Add(_regHelper);

            if (options.IsViewer)
            {
                this.DoViewerStuff();

                return(0);
            }

            bool isErrorCodes = _regOptions.ErrorCodes;

            if (_regOptions.ShowLogo)
            {
                _regHelper.DisplayLogo();
            }
            if (_regOptions.ShowHelp || _regOptions.Count == 0)
            {
                _regHelper.DisplayHelp();

                return(isErrorCodes ? 1 : -1);
            }

            if (!ApplicationHelpers.IsClassRegistered(
                    "{31411198-A502-11D2-BBCA-00C04F8EC294}"))
            {
                if (!_regOptions.IsQuiet)
                {
                    _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                           "ErrorNoHelp2Environment")));
                }

                return(isErrorCodes ? 2 : -1);
            }

            if (!ApplicationHelpers.IsThisUserPrivileged())
            {
                if (!_regOptions.IsQuiet)
                {
                    _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                           "ErrorInvalidPrivileges")));
                }

                return(isErrorCodes ? 3 : -1);
            }

            string actionParam = _regOptions.ActionParam;

            if (actionParam != "/r" && actionParam != "/u" && actionParam != "+r" &&
                actionParam != "-r" && actionParam != "+p" && actionParam != "-p" &&
                actionParam != "/v" && actionParam != "-v")
            {
                if (!_regOptions.IsQuiet)
                {
                    _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                           "ErrorInvalidCommandLine"), actionParam));
                }

                return(isErrorCodes ? 4 : -1);
            }

            if (String.IsNullOrEmpty(_regOptions.FileName) ||
                !File.Exists(_regOptions.FileName))
            {
                if (!_regOptions.IsQuiet)
                {
                    _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                           "ErrorInvalidXmlFile"), _regOptions.FileName));
                }

                return(isErrorCodes ? 5 : -1);
            }

            XmlValidator schemaValidator = new XmlValidator(helper);

            if (!schemaValidator.SchemaExists)
            {
                if (!_regOptions.IsQuiet)
                {
                    _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                           "ErrorCannotValidateXmlFile"), _regOptions.FileName));
                }

                return(isErrorCodes ? 6 : -1);
            }

            if (!schemaValidator.Validate(_regOptions.FileName, _regOptions.IsQuiet))
            {
                // get a message from the validator class
                return(isErrorCodes ? 6 : -1);
            }

            if (actionParam != "/v" && actionParam != "-v")
            {
                _regHelper.CloseViewers();
            }

            if (actionParam == "/r" || actionParam == "+r")
            {
                this.DoHelpStuff(true);
            }
            if (actionParam == "/r" || actionParam == "+p")
            {
                this.DoPluginStuff(true);
            }
            if (actionParam == "/u" || actionParam == "-p")
            {
                this.DoPluginStuff(false);
            }
            if (actionParam == "/u" || actionParam == "-r")
            {
                this.DoHelpStuff(false);
            }
            if (actionParam == "/v" || actionParam == "-v" ||
                _regOptions.ViewHelp)
            {
                this.DoViewerStuff();
            }

            return(0);
        }