XamlException IAddLineInfo.WithLineInfo(XamlException ex)
 {
     if (this.EndInstanceLineNumber > 0)
     {
         ex.SetLineInfo(this.EndInstanceLineNumber, this.EndInstanceLinePosition);
     }
     return ex;
 }
        public XamlException(string message, Exception innerException) : base(message, innerException)
        {
            XamlException exception = innerException as XamlException;

            if (exception != null)
            {
                this.LineNumber   = exception.LineNumber;
                this.LinePosition = exception.LinePosition;
            }
        }
Exemple #3
0
        public XamlException(string message, Exception innerException)
            : base(message, innerException)
        {
            XamlException xex = innerException as XamlException;

            if (xex != null)
            {
                LineNumber   = xex.LineNumber;
                LinePosition = xex.LinePosition;
            }
        }
Exemple #4
0
        internal static XamlParseException WrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
        {
            Exception baseException = (e.InnerException == null) ? e : e.InnerException;

            if (baseException is System.Windows.Markup.XamlParseException)
            {
                var xe = ((System.Windows.Markup.XamlParseException)baseException);
                xe.BaseUri = xe.BaseUri ?? baseUri;
                if (lineInfo != null && xe.LinePosition == 0 && xe.LineNumber == 0)
                {
                    xe.LinePosition = lineInfo.LinePosition;
                    xe.LineNumber   = lineInfo.LineNumber;
                }
                return(xe);
            }
            if (e is System.Xaml.XamlException)
            {
                System.Xaml.XamlException xe = (System.Xaml.XamlException)e;
                return(new XamlParseException(xe.Message, xe.LineNumber, xe.LinePosition, baseUri, baseException));
            }
            else if (e is XmlException)
            {
                XmlException xe = (XmlException)e;
                return(new XamlParseException(xe.Message, xe.LineNumber, xe.LinePosition, baseUri, baseException));
            }
            else
            {
                if (lineInfo != null)
                {
                    return(new XamlParseException(e.Message, lineInfo.LineNumber, lineInfo.LinePosition, baseUri, baseException));
                }
                else
                {
                    return(new XamlParseException(e.Message, baseException));
                }
            }
        }
 private XamlException WithLineInfo(XamlException ex)
 {
     ex.SetLineInfo(this._lineNumber, this._linePosition);
     return ex;
 }
 XamlException IAddLineInfo.WithLineInfo(XamlException ex)
 {
     return this.WithLineInfo(ex);
 }
Exemple #7
0
        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;
            }
        }
Exemple #8
0
 XamlException WithLineInfo(XamlException ex)
 {
     ex.SetLineInfo(LineNumber, LinePosition);
     return(ex);
 }
Exemple #9
0
 protected override XamlException WithLineInfo(XamlException ex)
 {
     ex.SetLineInfo(source.Line, source.Column);
     return(ex);
 }
Exemple #10
0
 XamlException WithLineInfo(XamlException ex)
 {
     ex.SetLineInfo(Line, Column);
     return(ex);
 }
        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;
        }
Exemple #12
0
 protected abstract XamlException WithLineInfo(XamlException ex);
 private XamlException LineInfo(XamlException e)
 {
     if (this._xmlLineInfo != null)
     {
         e.SetLineInfo(this._xmlLineInfo.LineNumber, this._xmlLineInfo.LinePosition);
     }
     return e;
 }