Ejemplo n.º 1
0
 private void RegisterOrRemoveNamespace(object sender, NamespaceEventArgs e)
 {
     if (e.Register)
     {
         _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                "RegisterHelpNamespace"), e.Name));
     }
     else
     {
         _regHelper.WriteLine(String.Format(ResourcesHelper.GetString(
                                                "RemoveHelpNamespace"), e.Name));
     }
 }
Ejemplo n.º 2
0
        private void ValidationCallback(object sender, ValidationEventArgs e)
        {
            if (!_beQuiet)
            {
                if (_regHelper != null)
                {
                    _regHelper.WriteLine(e.Message);
                }
            }

            _validationSuccess = false;
        }
Ejemplo n.º 3
0
        public void WriteLine(string text)
        {
            if (_listHandlers == null || _listHandlers.Count == 0)
            {
                return;
            }
            int itemCount = _listHandlers.Count;

            for (int i = 0; i < itemCount; i++)
            {
                IRegistrationHelper handler = _listHandlers[i];
                if (handler != null)
                {
                    if (String.IsNullOrEmpty(text))
                    {
                        handler.WriteLine();
                    }
                    else
                    {
                        handler.WriteLine(text);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void WriteLine()
        {
            if (_listHandlers == null || _listHandlers.Count == 0)
            {
                return;
            }
            int itemCount = _listHandlers.Count;

            for (int i = 0; i < itemCount; i++)
            {
                IRegistrationHelper handler = _listHandlers[i];
                if (handler != null)
                {
                    handler.WriteLine();
                }
            }
        }
Ejemplo n.º 5
0
        public void WriteLine(COMException exception)
        {
            if (_ignoreExceptions || exception == null ||
                _listHandlers == null || _listHandlers.Count == 0)
            {
                return;
            }
            int itemCount = _listHandlers.Count;

            for (int i = 0; i < itemCount; i++)
            {
                IRegistrationHelper handler = _listHandlers[i];
                if (handler != null)
                {
                    handler.WriteLine(exception);
                }
            }
        }
Ejemplo n.º 6
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);
        }