private void AttachTextBlockHandlers() { var children = LogicalTreeHelper.GetChildren(this); textBlock = children.OfType <TextBlock>().FirstOrDefault(); if (textBlock == null) { var textBlockException = new XamlException("TextBlockScaler cannot find a TextBlock in its collection of child elements"); Log.Error(textBlockException); throw textBlockException; } if (textBlock.IsLoaded) //Loaded event is fired from the root down; we may be here before the child TextBlock has loaded, so check { SetupTextBlockHandlers(); CalculateTextBlockFontSize(); } else { RoutedEventHandler textBlockLoaded = null; textBlockLoaded = (_, __) => { SetupTextBlockHandlers(); CalculateTextBlockFontSize(); textBlock.Loaded -= textBlockLoaded; }; textBlock.Loaded += textBlockLoaded; } }
internal static bool TryWrapSupportedVersionException(string filePath, Exception e, out Exception newException) { // We replace the exception, rather than simply wrapping it, because the activation error page highlights // the innermost exception, and we want that exception to clearly show which file is the culprit. // Of course, if the exception has an inner exception, that will still get highlighted instead. // Also, for Xaml and XmlException, we don't propagate the line info, because the exception message already contains it. if (e is XmlException) { newException = new XmlException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException); return(true); } if (e is XamlException) { newException = new XamlException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException); return(true); } if (e is InvalidWorkflowException) { newException = new InvalidWorkflowException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException); return(true); } if (e is ValidationException) { newException = new ValidationException(SR.ExceptionLoadingSupportedVersion(filePath, e.Message), e.InnerException); return(true); } newException = null; return(false); }
void RaiseLoadError(Exception e) { if (this.xamlLoadErrorService != null) { XamlLoadErrorInfo errorInfo = null; XamlException xamlEx = e as XamlException; if (xamlEx != null) { errorInfo = new XamlLoadErrorInfo(xamlEx.Message, xamlEx.LineNumber, xamlEx.LinePosition); } else { XmlException xmlEx = e as XmlException; if (xmlEx != null) { errorInfo = new XamlLoadErrorInfo(xmlEx.Message, xmlEx.LineNumber, xmlEx.LinePosition); } } if (errorInfo != null) { var errors = new XamlLoadErrorInfo[] { errorInfo }; xamlLoadErrorService.ShowXamlLoadErrors(errors); } } }
XamlException LineInfo(XamlException e) { if (_xmlLineInfo != null) { e.SetLineInfo(_xmlLineInfo.LineNumber, _xmlLineInfo.LinePosition); } return(e); }
XamlException IAddLineInfo.WithLineInfo(XamlException ex) { if (this.LineNumber > 0) { ex.SetLineInfo(this.LineNumber, this.LinePosition); } return(ex); }
XamlException IAddLineInfo.WithLineInfo(XamlException ex) { if (EndInstanceLineNumber > 0) { ex.SetLineInfo(EndInstanceLineNumber, EndInstanceLinePosition); } return(ex); }
private XamlException LineInfo(XamlException e) { if (this._xmlLineInfo != null) { e.SetLineInfo(this._xmlLineInfo.LineNumber, this._xmlLineInfo.LinePosition); } return(e); }
// Method to easily add the lineinfo to a Xaml Exception. public XamlException WithLineInfo(XamlException ex) { ex.SetLineInfo(LineNumber, LinePosition); return(ex); }
public SourceCodeError GetSourceCodeError(XamlException exception) { return(new SourceCodeError( GetExceptionMessage(exception), TryGetSingleLineLocation(lineNumber: exception.LineNumber - 1, positionInLine: exception.LinePosition - 1, text: Document.Text))); }
protected override XamlException WithLineInfo(XamlException ex) { ex.SetLineInfo(source.Line, source.Column); return(ex); }
XamlException WithLineInfo(XamlException ex) { ex.SetLineInfo(Line, Column); return(ex); }
protected override XamlException WithLineInfo(XamlException ex) { return(ex); }
protected abstract XamlException WithLineInfo(XamlException ex);