Esempio n. 1
0
        private void Parse(bool IsExplicit)
        {
            ClearDispatcherTimer();

            if (XamlDocument != null && !CodeCompletionPopup.IsOpenSomewhere)
            {
                if (XamlDocument.SourceText != null)
                {
                    bool parseSuccess = false;
                    parseSuccess = (bool)this.ContentArea.InvokeScript("ParseXaml", new object[] { XamlDocument.SourceText });

                    if (parseSuccess)
                    {
                        IsValidXaml       = true;
                        ErrorText         = null;
                        ErrorLineNumber   = 0;
                        ErrorLinePosition = 0;

                        if (Kaxaml.Properties.Settings.Default.EnableAutoBackup)
                        {
                            XamlDocument.SaveBackup();
                        }

                        DelayedSnapshot();
                    }
                    else
                    {
                        ErrorText         = (string)this.ContentArea.InvokeScript("GetLastErrorMessage", null);
                        ErrorLineNumber   = int.Parse((string)this.ContentArea.InvokeScript("GetLastErrorLineNumber", null));
                        ErrorLinePosition = int.Parse((string)this.ContentArea.InvokeScript("GetLastErrorLinePos", null));

                        ErrorText = ErrorText.Replace("\r", "");
                        ErrorText = ErrorText.Replace("\n", "");
                        ErrorText = ErrorText.Replace("\t", "");

                        // get rid of everything after "Line" if it is in the last 30 characters
                        int pos = ErrorText.LastIndexOf("[Line");
                        if (pos > 0 && pos > (ErrorText.Length - 50))
                        {
                            ErrorText = ErrorText.Substring(0, pos);
                        }

                        IsValidXaml = false;
                    }
                }
            }
        }
Esempio n. 2
0
        private void ReportError(Exception e)
        {
            IsValidXaml = false;

            if (e is XamlParseException)
            {
                XamlParseException x = (XamlParseException)e;
                ErrorLineNumber   = x.LineNumber;
                ErrorLinePosition = x.LinePosition;
            }
            else
            {
                ErrorLineNumber   = 0;
                ErrorLinePosition = 0;
            }

            Exception inner = e;

            while (inner.InnerException != null)
            {
                inner = inner.InnerException;
            }

            ErrorText = inner.Message;
            ErrorText = ErrorText.Replace("\r", "");
            ErrorText = ErrorText.Replace("\n", "");
            ErrorText = ErrorText.Replace("\t", "");

            // get rid of everything after "Line" if it is in the last 30 characters
            int pos = ErrorText.LastIndexOf("Line");

            if (pos > 0 && pos > (ErrorText.Length - 50))
            {
                ErrorText = ErrorText.Substring(0, pos);
            }
        }