private static void AssertFormatting(string expected, ISST sst)
        {
            var sut = new XamlSSTPrintingContext();

            sst.Accept(new SSTPrintingVisitor(), sut);
            var actual = sut.ToString();

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        private void TestPrintingWithHighlightingProducesValidXaml(ISSTNode sst)
        {
            var context = new XamlSSTPrintingContext();

            sst.Accept(_sut, context);
            var actual = context.ToString();

            // throws and fails test if markup is invalid
            XamlUtils.CreateDataTemplateFromXaml(actual);
        }
Пример #3
0
        private string GetContextAsXaml()
        {
            Context ctx = null;

            var completionEvent = Event as CompletionEvent;

            if (completionEvent != null)
            {
                ctx = completionEvent.Context2;
            }

            var editEvent = Event as EditEvent;

            if (editEvent != null)
            {
                ctx = editEvent.Context2;
            }

            if (ctx != null)
            {
                var visitor        = new SSTPrintingVisitor();
                var printerContext = new XamlSSTPrintingContext {
                    TypeShape = ctx.TypeShape
                };
                visitor.Visit(ctx.SST, printerContext);

                var usingListContext = new XamlSSTPrintingContext();
                printerContext.SeenNamespaces.FormatAsUsingList(usingListContext);

                return(String.Concat(
                           usingListContext.ToString(),
                           Environment.NewLine,
                           Environment.NewLine,
                           printerContext.ToString()));
            }

            return(null);
        }