public override FormError Add(XPathNavigator context, string name, string message, string messageDetails, int errorCode, ErrorMode errorMode)
        {
            var newFormError = new FormErrorMock(context as XPathNavigatorMock, name, message, messageDetails, errorCode, errorMode);
            this._formErrors.Add(newFormError);

            return newFormError;
        }
        public ZuneMessageBox(string errorMessage, ErrorMode mode, MessageBoxButton buttons)
            : this()
        {
            InitializeComponent();

            switch (mode)
            {
                case ErrorMode.Error:
                    tbMessageTitle.Text = "ERROR";
                    break;
                case ErrorMode.Warning:
                    tbMessageTitle.Text = "WARNING";
                    break;
                case ErrorMode.Info:
                    tbMessageTitle.Text = "INFO";
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (buttons == MessageBoxButton.YesNo)
            {
                btnOk.Content = "YES";
                btnCancel.Content = "NO";
            }

            this.imgErrorIcon.Source = new BitmapImage(new Uri(GetIconUriForErrorMode(mode), UriKind.RelativeOrAbsolute));
            this.tbErrorMessage.Text = errorMessage;
            this.tbErrorMessage.ToolTip = errorMessage;
        }
Esempio n. 3
0
 public ChangeErrorMode(ErrorMode mode)
 {
    if (IsAtLeastWindows7)
       SetThreadErrorMode(mode, out _oldMode);
    else
       _oldMode = SetErrorMode(mode);
 }
Esempio n. 4
0
 public FormErrorMock(XPathNavigatorMock site, string name, string message, string detailedMessage = null, int errorCode = 0, ErrorMode errorMode = ErrorMode.Modal)
 {
     this._site = site;
     this._name = name;
     this.Message = message;
     this.DetailedMessage = detailedMessage;
     this.ErrorCode = errorCode;
 }
        public BBCodeParser(ErrorMode errorMode, string textNodeHtmlTemplate, IList<BBTag> tags)
        {
            if (!Enum.IsDefined(typeof(ErrorMode), errorMode)) throw new ArgumentOutOfRangeException("errorMode");
            if (tags == null) throw new ArgumentNullException("tags");

            ErrorMode = errorMode;
            TextNodeHtmlTemplate = textNodeHtmlTemplate;
            Tags = tags;
        }
Esempio n. 6
0
        public void TestRemoteResultError()
        {
            Mode = ErrorMode.RmtResErr;

            GoodException e = ExecuteWithError() as GoodException;

            Assert.IsNotNull(e);

            Assert.AreEqual(ErrorMode.RmtResErr, e.Mode);
        }
Esempio n. 7
0
        public void TestRemoteResultErrorNotMarshalable()
        {
            Mode = ErrorMode.RmtResErrNotMarshalable;

            BadException e = ExecuteWithError() as BadException;

            Assert.IsNotNull(e);

            Assert.AreEqual(ErrorMode.RmtResErrNotMarshalable, e.Mode);
        }
Esempio n. 8
0
        public void TestMapError()
        {
            Mode = ErrorMode.MapErr;

            GoodException e = ExecuteWithError() as GoodException;

            Assert.IsNotNull(e);

            Assert.AreEqual(ErrorMode.MapErr, e.Mode);
        }
Esempio n. 9
0
        public void TestMapNotMarshalableError()
        {
            Mode = ErrorMode.MapErrNotMarshalable;

            BadException e = ExecuteWithError() as BadException;

            Assert.IsNotNull(e);

            Assert.AreEqual(ErrorMode.MapErrNotMarshalable, e.Mode);
        }
Esempio n. 10
0
        public void TestLocalJobResultNotMarshalable()
        {
            Mode = ErrorMode.LocJobResNotMarshalable;

            int res = Execute();

            Assert.AreEqual(2, res); // Local job result is not marshalled.

            Assert.AreEqual(0, JobErrs.Count);
        }
Esempio n. 11
0
        public static void showErrorText(GameObject errText, ErrorMode errCode, string AdditionalInfo)
        {
            string errInfo;

            errText.SetActive(true);
            errInfo  = GetErrorText(errCode);
            errInfo += System.Environment.NewLine;
            errInfo += LocaleManager.instance.GetLocaleText("error_additional") + AdditionalInfo;
            errText.GetComponent <Text>().text = errInfo;
        }
        public void TestLocalResultError()
        {
            _mode = ErrorMode.LocResErr;

            GoodException e = ExecuteWithError() as GoodException;

            Assert.IsNotNull(e);

            Assert.AreEqual(ErrorMode.LocResErr, e.Mode);
        }
        public void TestRemoteResultErrorNotMarshalable()
        {
            _mode = ErrorMode.RmtResErrNotMarshalable;

            var err          = ExecuteWithError();
            var badException = err as BadException;

            Assert.IsNotNull(badException, err.ToString());
            Assert.AreEqual(ErrorMode.RmtResErrNotMarshalable, badException.Mode);
        }
 public BBCodeParser(ErrorMode errorMode, string textNodeHtmlTemplate, IList <BBTag> tags)
 {
     if (!Enum.IsDefined(typeof(ErrorMode), errorMode))
     {
         throw new ArgumentOutOfRangeException("errorMode");
     }
     ErrorMode            = errorMode;
     TextNodeHtmlTemplate = textNodeHtmlTemplate;
     Tags = tags ?? throw new ArgumentNullException("tags");
 }
Esempio n. 15
0
        public static void showErrorText(GameObject errText, ErrorMode errCode)
        {
            string errInfo;

            errText.SetActive(true);
            errInfo  = GetErrorText(errCode);
            errInfo += System.Environment.NewLine;
            errInfo += LocaleManager.instance.GetLocaleText("error_errornum") + ((byte)errCode).ToString();
            errText.GetComponent <Text>().text = errInfo;
        }
        public void TestLocalJobErrorNotMarshalable()
        {
            _mode = ErrorMode.LocJobErrNotMarshalable;

            int res = Execute();

            Assert.AreEqual(1, res);

            Assert.AreEqual(4, JobErrs.Count);
            Assert.IsInstanceOf <BadException>(JobErrs.First().InnerException); // Local job exception is not marshalled.
        }
Esempio n. 17
0
 /// <summary>ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups.</summary>
 /// <param name="mode">One of the <see cref="ErrorMode"/> values.</param>
 public ChangeErrorMode(ErrorMode mode)
 {
     if (IsAtLeastWindows7)
     {
         SetThreadErrorMode(mode, out _oldMode);
     }
     else
     {
         _oldMode = SetErrorMode(mode);
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Set a new error mode for the current thread.
        /// </summary>
        /// <returns>The old error mode for the thread.</returns>
        public static ErrorMode SetThreadErrorMode(ErrorMode mode)
        {
            ErrorMode oldMode;

            if (!Direct.SetThreadErrorMode(mode, out oldMode))
            {
                throw ErrorHelper.GetIoExceptionForLastError();
            }

            return(oldMode);
        }
Esempio n. 19
0
 public ChangeErrorMode(ErrorMode mode)
 {
     if (IsAtLeastWindows7())
     {
         NativeMethods.SetThreadErrorMode(mode, out _oldMode);
     }
     else
     {
         _oldMode = NativeMethods.SetErrorMode(mode);
     }
 }
Esempio n. 20
0
        public void TestLocalJobErrorNotMarshalable()
        {
            Mode = ErrorMode.LocJobErrNotMarshalable;

            int res = Execute();

            Assert.AreEqual(1, res);

            Assert.AreEqual(4, JobErrs.Count);
            Assert.IsNotNull(JobErrs.First() as BadException); // Local job exception is not marshalled.
        }
Esempio n. 21
0
 public static bool IsValid(string bbCode, ErrorMode errorMode)
 {
     try
     {
         BBCodeParserTest.BBEncodeForTest(bbCode, errorMode);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 22
0
        public void TestRemoteJobResultNotMarshalable()
        {
            Mode = ErrorMode.RmtJobResNotMarshalable;

            int res = Execute();

            Assert.AreEqual(1, res);

            Assert.AreEqual(4, JobErrs.Count);

            Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
        }
Esempio n. 23
0
        public void TestLocalJobError()
        {
            Mode = ErrorMode.LocJobErr;

            int res = Execute();

            Assert.AreEqual(1, res);

            Assert.AreEqual(4, JobErrs.Count);
            Assert.IsNotNull(JobErrs.First() as GoodException);
            Assert.AreEqual(ErrorMode.LocJobErr, ((GoodException)JobErrs.First()).Mode);
        }
Esempio n. 24
0
 private TemporaryErrorMode(ErrorMode modesToEnable)
 {
     _oldMode = Error.GetThreadErrorMode();
     if ((_oldMode & modesToEnable) != modesToEnable)
     {
         _oldMode        = Error.SetThreadErrorMode(_oldMode | modesToEnable);
         _restoreOldMode = true;
     }
     else
     {
         _restoreOldMode = false;
     }
 }
Esempio n. 25
0
 public void NoScript_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input)
 {
     PexAssume.EnumIsDefined(errorMode);
     try
     {
         var output = BBEncodeForTest(input, errorMode);
         PexAssert.IsTrue(!output.Contains("<script"));
     }
     catch (BBCodeParsingException)
     {
         PexAssume.Fail();
     }
 }
        public FileDelimitedExtract(AbstractConnection connection, Entity entity, int top = 0) {

            var fileInfo = new FileInfo(connection.File);

            _entity = entity;
            _top = top;
            _fields = entity.Fields.WithInput().ToArray();
            _delimiter = connection.Delimiter;
            _fullName = fileInfo.FullName;
            _name = fileInfo.Name;
            _ignoreFirstLines = connection.Start - 1;
            _errorMode = connection.ErrorMode;
        }
        public FileDelimitedExtract(AbstractConnection connection, Entity entity, int top = 0)
        {
            var fileInfo = new FileInfo(connection.File);

            _entity           = entity;
            _top              = top;
            _fields           = entity.Fields.WithInput().ToArray();
            _delimiter        = connection.Delimiter;
            _fullName         = fileInfo.FullName;
            _name             = fileInfo.Name;
            _ignoreFirstLines = connection.Start - 1;
            _errorMode        = connection.ErrorMode;
        }
Esempio n. 28
0
        public void Roundtrip(ErrorMode errorMode, out string bbcode, out string output)
        {
            PexAssume.EnumIsDefined(errorMode);

            var parser = BBCodeTestUtil.GetParserForTest(errorMode, false, BBTagClosingStyle.AutoCloseElement, false);
            var tree   = BBCodeTestUtil.CreateRootNode(parser.Tags.ToArray());

            bbcode = tree.ToBBCode();
            var tree2 = parser.ParseSyntaxTree(bbcode);

            output = tree2.ToHtml();
            Assert.IsTrue(tree == tree2);
        }
        /// <summary>
        /// Gets the data from file.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="errorMode">The error mode.</param>
        /// <param name="isFirstLineHeader">if set to <c>true</c> [the file's first line will be considered as a header file].</param>
        /// <returns>Return an object that contains source's data (file) converted to TDestination object with Errors
        /// (business and technical) if any.</returns>
        public IDataOutputResult <TDestination> GetDataFromFile(string filePath, ErrorMode errorMode, bool isFirstLineHeader)
        {
            switch (errorMode)
            {
            case ErrorMode.ThrowException:
                fileEngine.ErrorManager.ErrorMode = FileHelpers.ErrorMode.ThrowException;
                break;

            case ErrorMode.SaveAndContinue:
                fileEngine.ErrorManager.ErrorMode = FileHelpers.ErrorMode.SaveAndContinue;
                break;

            case ErrorMode.IgnoreAndContinue:
                fileEngine.ErrorManager.ErrorMode = FileHelpers.ErrorMode.IgnoreAndContinue;
                break;
            }

            if (isFirstLineHeader)
            {
                fileEngine.Options.IgnoreFirstLines = 1;
            }

            try
            {
                TSource[]            data          = fileEngine.ReadFile(filePath);
                List <IErrorMessage> errors        = fileEngine.ErrorManager.GetFileTechnicalErrors();
                List <TDestination>  convertedData = new List <TDestination>();
                foreach (var item in data)
                {
                    ITransformedResult <TDestination> transformedResult = item.GetTransformed();
                    if (transformedResult.HasError)
                    {
                        errors.Add(transformedResult.ErrorMessage);
                    }
                    if (!transformedResult.IsTechnicalError)
                    {
                        convertedData.Add(transformedResult.ResultData);
                    }
                }

                return(new DataOutputResult <TDestination>(errors, convertedData));
            }
            catch (Exception ex)
            {
                List <IErrorMessage> errorList = new List <IErrorMessage>();
                IErrorMessage        error     = new ErrorMessage(ErrorMessageType.TechnicalMessage);
                errorList.Add(error);
                error.Message = ex.InnerException.IsNotNull() ? ex.InnerException.Message : ex.Message;
                return(new DataOutputResult <TDestination>(errorList, null));
            }
        }
 private static string GetErrorImageFor(ErrorMode errorMode)
 {
     switch (errorMode)
     {
         case ErrorMode.Error:
             return "../Resources/Assets/no.png";
         case ErrorMode.Warning:
             return "../Resources/Assets/warning.png";
         case ErrorMode.Info:
             return "../Resources/Assets/information.png";
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
        public void TestLocalJobError()
        {
            _mode = ErrorMode.LocJobErr;

            int res = Execute();

            Assert.AreEqual(1, res);

            Assert.AreEqual(4, JobErrs.Count);
            var goodEx = JobErrs.First().InnerException as GoodException;

            Assert.IsNotNull(goodEx);
            Assert.AreEqual(ErrorMode.LocJobErr, goodEx.Mode);
        }
Esempio n. 32
0
        public BBCodeParser(ErrorMode errorMode, IList <BBTag> tags)
        {
            if (!Enum.IsDefined(typeof(ErrorMode), errorMode))
            {
                throw new ArgumentOutOfRangeException("errorMode");
            }
            if (tags == null)
            {
                throw new ArgumentNullException("tags");
            }

            ErrorMode = errorMode;
            Tags      = tags;
        }
Esempio n. 33
0
        public void TestRemoteJobError()
        {
            Mode = ErrorMode.RmtJobErr;

            int res = Execute();

            Assert.AreEqual(1, res);

            Assert.AreEqual(4, JobErrs.Count);

            Assert.IsNotNull(JobErrs.ElementAt(0) as GoodException);

            Assert.AreEqual(ErrorMode.RmtJobErr, ((GoodException)JobErrs.ElementAt(0)).Mode);
        }
Esempio n. 34
0
        public void ThrowError(ErrorMode errMode)
        {
            HasError = true;
            MessageBox.Show(LocaleManager.instance.GetLocaleText("error_occured"), ErrorManager.GetErrorText(errMode), MessageBoxButton.OK);
            StartCoroutine(MessageAct_ThrowError());
#if UNITY_ANDROID
            if (Social.localUser.authenticated)
            {
                PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement_never_give_up, 1, null);
            }
#elif UNITY_IOS
            Achievementer.ReportProgress("nevergiveup", 20.0f);
#endif
        }
Esempio n. 35
0
 public void NoHtmlChars_AnyInput(ErrorMode errorMode, [PexAssumeNotNull] string input)
 {
     PexAssume.EnumIsDefined(errorMode);
     try
     {
         var output = BBCodeTestUtil.SimpleBBEncodeForTest(input, errorMode);
         PexObserve.ValueForViewing("output", output);
         PexAssert.IsTrue(output.IndexOf('<') == -1);
         PexAssert.IsTrue(output.IndexOf('>') == -1);
     }
     catch (BBCodeParsingException)
     {
         PexAssume.Fail();
     }
 }
Esempio n. 36
0
 public void NoCrash(ErrorMode errorMode, [PexAssumeNotNull] string input, BBTagClosingStyle listItemBbTagClosingStyle, out string output)
 {
     PexAssume.EnumIsDefined(errorMode);
     PexAssume.EnumIsDefined(listItemBbTagClosingStyle);
     try
     {
         output = BBEncodeForTest(input, errorMode, listItemBbTagClosingStyle, false);
         Assert.IsNotNull(output);
     }
     catch (BBCodeParsingException)
     {
         Assert.AreNotEqual(ErrorMode.ErrorFree, errorMode);
         output = null;
     }
 }
Esempio n. 37
0
 public BootstrapValidationSummaryOptions(ErrorMode mode           = ErrorMode.Alert,
                                          bool showModelErrors     = true,
                                          string title             = "Opps! There seems to be a problem.",
                                          string introductionBlock = "",
                                          AlertStyleSettings alertStyleSettings = null,
                                          PanelStyleSettings panelStyleSettings = null,
                                          ModalStyleSettings modalStyleSettings = null)
 {
     DisplayMode          = mode;
     ShowModelErrors      = showModelErrors;
     Title                = title;
     IntroductionBlock    = introductionBlock;
     AlertDisplaySettings = (alertStyleSettings == null) ? new AlertStyleSettings() : alertStyleSettings;
     PanelDisplaySettings = (panelStyleSettings == null) ? new PanelStyleSettings() : panelStyleSettings;
     ModalDisplaySettings = (modalStyleSettings == null) ? new ModalStyleSettings() : modalStyleSettings;
 }
 public static BBCodeParser GetParserForTest(ErrorMode errorMode, bool includePlaceholder, BBTagClosingStyle listItemBBTagClosingStyle, bool enableIterationElementBehavior)
 {
     return new BBCodeParser(errorMode, null, new[]
         {
             new BBTag("b", "<b>", "</b>"), 
             new BBTag("i", "<span style=\"font-style:italic;\">", "</span>"), 
             new BBTag("u", "<span style=\"text-decoration:underline;\">", "</span>"), 
             new BBTag("code", "<pre class=\"prettyprint\">", "</pre>"), 
             new BBTag("img", "<img src=\"${content}\" />", "", false, true), 
             new BBTag("quote", "<blockquote>", "</blockquote>"), 
             new BBTag("list", "<ul>", "</ul>"), 
             new BBTag("*", "<li>", "</li>", true, listItemBBTagClosingStyle, null, enableIterationElementBehavior), 
             new BBTag("url", "<a href=\"${href}\">", "</a>", new BBAttribute("href", ""), new BBAttribute("href", "href")), 
             new BBTag("url2", "<a href=\"${href}\">", "</a>", new BBAttribute("href", "", GetUrl2Href), new BBAttribute("href", "href", GetUrl2Href)), 
             !includePlaceholder ? null : new BBTag("placeholder", "${name}", "", false, BBTagClosingStyle.LeafElementWithoutContent, null, new BBAttribute("name", "", name => "xxx" + name.AttributeValue + "yyy")), 
         }.Where(x => x != null).ToArray());
 }
            public BootstrapValidationSummaryOptions(ErrorMode mode = ErrorMode.Alert,
                                                        bool showModelErrors = true,
                                                        string title = "Oops! There seems to be a problem.",
                                                        string introductionBlock = "There seems to have been a problem with your request. See below: ",
                                                        bool enableRequiredFieldIndicators = true,
                                                        bool enableRequiredFieldHelp = true,
                                                        AlertStyleSettings alertStyleSettings = null,
                                                        PanelStyleSettings panelStyleSettings = null,
                                                        ModalStyleSettings modalStyleSettings = null)
            {
                DisplayMode = mode;
                ShowModelErrors = showModelErrors;
                Title = title;
                IntroductionBlock = introductionBlock;
                EnableRequiredFieldIndicators = enableRequiredFieldIndicators;
                EnableRequiredFieldHelp = enableRequiredFieldHelp;
                AlertDisplaySettings = (alertStyleSettings == null) ? new AlertStyleSettings() : alertStyleSettings;
                PanelDisplaySettings = (panelStyleSettings == null) ? new PanelStyleSettings() : panelStyleSettings;
                ModalDisplaySettings = (modalStyleSettings == null) ? new ModalStyleSettings() : modalStyleSettings;


            }
        public FileFixedExtract(AbstractConnection connection, Entity entity, int top = 0) {
            var fileInfo = new FileInfo(connection.File);

            _entity = entity;
            _top = top;
            _fields = _entity.Fields.WithInput().ToArray();
            _fullName = fileInfo.FullName;
            _name = fileInfo.Name;
            _errorMode = connection.ErrorMode;
            int ignoreFirstLines = connection.Start - 1;

            _classBuilder = new FixedLengthClassBuilder("Tfl" + _entity.Alias) {
                IgnoreEmptyLines = true,
                IgnoreFirstLines = ignoreFirstLines
            };
            foreach (var field in _fields) {
                var length = field.Length.Equals("max", IC) ? int.MaxValue : Convert.ToInt32(field.Length.Equals(string.Empty) ? "64" : field.Length);
                var builder = new FixedFieldBuilder(field.Alias, length, typeof(string)) {
                    FieldNullValue = new String(' ', length)
                };
                _classBuilder.AddField(builder);
            }

        }
 public static string SimpleBBEncodeForTest(string bbCode, ErrorMode errorMode)
 {
     return GetSimpleParserForTest(errorMode).ToHtml(bbCode);
 }
 public static bool IsValid(string bbCode, ErrorMode errorMode)
 {
     try
     {
         BBCodeParserTest.BBEncodeForTest(bbCode, errorMode);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Esempio n. 43
0
 /// <summary>Initializes a new instance of the <see cref="ErrorManager"/> class. with the specified <see cref="ErrorMode"/>.</summary>
 /// <param name="mode">Indicates the error behavior of the class.</param>
 public ErrorManager(ErrorMode mode)
 {
     mErrorMode = mode;
 }
 public static BBCodeParser GetSimpleParserForTest(ErrorMode errorMode)
 {
     return new BBCodeParser(errorMode, null, new[]
         {
             new BBTag("x", "${content}${x}", "${y}", true, true, new BBAttribute("x", "x"), new BBAttribute("y", "y", x => x.AttributeValue)), 
         });
 }
Esempio n. 45
0
 private static extern bool SetThreadErrorMode(ErrorMode dwNewMode, [MarshalAs(UnmanagedType.U4)] out ErrorMode lpOldMode);
Esempio n. 46
0
 private static extern ErrorMode SetErrorMode(ErrorMode uMode);
        public void TextNodesCannotBeSplit(ErrorMode errorMode, [PexAssumeNotNull] string input)
        {
            PexAssume.EnumIsDefined(errorMode);

            var parser = BBCodeTestUtil.GetParserForTest(errorMode, true, BBTagClosingStyle.AutoCloseElement, false);
            SequenceNode tree;
            try
            {
                tree = parser.ParseSyntaxTree(input);
            }
#pragma warning disable 168
            catch (BBCodeParsingException e)
#pragma warning restore 168
            {
                PexAssume.Fail();
                return;
            }

            AssertTextNodesNotSplit(tree);
        }
 public static string BBEncodeForTest(string bbCode, ErrorMode errorMode, BBTagClosingStyle listItemBbTagClosingStyle, bool enableIterationElementBehavior)
 {
     return BBCodeTestUtil.GetParserForTest(errorMode, true, listItemBbTagClosingStyle, enableIterationElementBehavior).ToHtml(bbCode).Replace("\r", "").Replace("\n", "<br/>");
 }
Esempio n. 49
0
 /// <summary>
 ///     Set the behavior on error
 /// </summary>
 /// <param name="errorMode">The error mode.</param>
 public FileEngine OnError(ErrorMode errorMode)
 {
     engine.ErrorManager.ErrorMode = errorMode;
     return this;
 }
Esempio n. 50
0
        private static void FlushMessage(ErrorMode currentErrorMode, string message)
        {
            switch (currentErrorMode)
            {
                case ErrorMode.Info:
                    Log.Info(message);
                    break;

                case ErrorMode.Warn:
                    Log.Warn(message);
                    break;

                case ErrorMode.Error:
                case ErrorMode.Critical:
                    throw new SolverException(message.Trim());
            }
        }
 public static string BBEncodeForTest(string bbCode, ErrorMode errorMode)
 {
     return BBEncodeForTest(bbCode, errorMode, BBTagClosingStyle.AutoCloseElement, false);
 }
Esempio n. 52
0
 internal static extern ErrorMode SetErrorMode(ErrorMode mode);
        public void Roundtrip2(ErrorMode errorMode, [PexAssumeNotNull] string input, out string bbcode, out string output)
        {
            PexAssume.EnumIsDefined(errorMode);

            var parser = BBCodeTestUtil.GetParserForTest(errorMode, false, BBTagClosingStyle.AutoCloseElement, false);
            SequenceNode tree;
            try
            {
                tree = parser.ParseSyntaxTree(input);
            }
#pragma warning disable 168
            catch (BBCodeParsingException e)
#pragma warning restore 168
            {
                PexAssume.Fail();
                tree = null;
            }

            bbcode = tree.ToBBCode();
            var tree2 = parser.ParseSyntaxTree(bbcode);
            output = tree2.ToHtml();
            Assert.IsTrue(tree == tree2);
        }
 public void NoScriptInAttributeValue(ErrorMode errorMode)
 {
     PexAssume.EnumIsDefined(errorMode);
     var encoded = BBEncodeForTest("[url=<script>][/url]", errorMode);
     Assert.IsFalse(encoded.Contains("<script"));
 }
        public void Roundtrip(ErrorMode errorMode, out string bbcode, out string output)
        {
            PexAssume.EnumIsDefined(errorMode);

            var parser = BBCodeTestUtil.GetParserForTest(errorMode, false, BBTagClosingStyle.AutoCloseElement, false);
            var tree = BBCodeTestUtil.CreateRootNode(parser.Tags.ToArray());
            bbcode = tree.ToBBCode();
            var tree2 = parser.ParseSyntaxTree(bbcode);
            output = tree2.ToHtml();
            Assert.IsTrue(tree == tree2);
        }
Esempio n. 56
0
        public string HandleStdErrorLine([NotNull] string line)
        {
            #region Sanity checks
            if (line == null) throw new ArgumentNullException("line");
            #endregion

            _handler.CancellationToken.ThrowIfCancellationRequested();

            var lineMode = IdentifyErrorMode(ref line);

            // Restore non-ASCII characters
            line = HttpUtility.HtmlDecode(line);

            switch (_currentErrorMode)
            {
                case ErrorMode.None:
                    _currentErrorMode = lineMode;
                    _cache = new StringBuilder();
                    if (!string.IsNullOrEmpty(line)) _cache.AppendLine(line);
                    break;

                case ErrorMode.Info:
                case ErrorMode.Warn:
                case ErrorMode.Error:
                case ErrorMode.Critical:
                    if (lineMode == ErrorMode.None) _cache.AppendLine(line);
                    else
                    {
                        FlushMessage(_currentErrorMode, _cache.ToString());

                        _currentErrorMode = lineMode;
                        _cache = new StringBuilder();
                        _cache.AppendLine(line);
                    }
                    break;

                case ErrorMode.Question:
                    if (lineMode == ErrorMode.None)
                    {
                        if (line.Contains("[Y/N]") && _currentErrorMode == ErrorMode.Question)
                        {
                            _currentErrorMode = ErrorMode.None;
                            return _handler.Ask(_cache.ToString(), defaultAnswer: false, alternateMessage: Resources.UntrustedKeys) ? "Y" : "N";
                        }
                        _cache.AppendLine(line);
                    }
                    else if (lineMode >= ErrorMode.Info && lineMode <= ErrorMode.Critical)
                        FlushMessage(_currentErrorMode, line);
                    else
                        throw new ArgumentException(@"Question within question is invalid", "line");
                    break;
            }

            return null;
        }
 public ZuneMessageBox(string errorMessage, ErrorMode mode, Action okClickedCallback)
     : this(errorMessage, mode, MessageBoxButton.OKCancel)
 {
     _okClickedCallback = okClickedCallback;
 }
Esempio n. 58
0
 public ErrorMessage(ErrorMode errorMode, string message)
 {
     this.ErrorMode = errorMode;
     this.Message = message;
 }
 private string GetIconUriForErrorMode(ErrorMode mode)
 {
     switch (mode)
     {
         case ErrorMode.Error:
             return "pack://application:,,,/Resources/Assets/error.png";
         case ErrorMode.Warning:
             return "pack://application:,,,/Resources/Assets/alert.png";
         case ErrorMode.Info:
             return "pack://application:,,,/Resources/Assets/info_big.png";
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
 public ConnectionBuilder ErrorMode(ErrorMode errorMode) {
     _connection.ErrorMode = errorMode.ToString();
     return this;
 }