public async void UpdatePreview(string text)
        {
            var workspace = new PreviewWorkspace(Ide.Composition.CompositionManager.Instance.HostServices);
            var fileName  = string.Format("project.{0}", Language == "C#" ? "csproj" : "vbproj");

            project = workspace.CurrentSolution.AddProject(fileName, "assembly.dll", Language);

            // use the mscorlib, system, and system.core that are loaded in the current process.
            string [] references =
            {
                "mscorlib",
                "System",
                "System.Core"
            };

            var metadataService = workspace.Services.GetService <IMetadataService> ();

            var referenceAssemblies = Thread.GetDomain().GetAssemblies()
                                      .Where(x => references.Contains(x.GetName(true).Name, StringComparer.OrdinalIgnoreCase))
                                      .Select(a => metadataService.GetReference(a.Location, MetadataReferenceProperties.Assembly));

            project = project.WithMetadataReferences(referenceAssemblies);

            var document  = project.AddDocument("document.cs", SourceText.From(text, Encoding.UTF8));
            var formatted = Formatter.FormatAsync(document, this.Options).WaitAndGetResult(CancellationToken.None);

            workspace.TryApplyChanges(project.Solution);

            TextViewHost.MimeType        = "text/x-csharp";
            TextViewHost.Text            = (await document.GetTextAsync()).ToString();
            TextViewHost.DocumentContext = new MyDocumentContext(workspace, document);

            TextViewHost.IsReadOnly = false;
            for (int i = 1; i <= TextViewHost.LineCount; i++)
            {
                var txt = TextViewHost.GetLineText(i);
                if (txt == "//[" || txt == "//]")
                {
                    var line = TextViewHost.GetLine(i);
                    TextViewHost.RemoveText(line.Offset, line.LengthIncludingDelimiter);
                    i--;
                }
            }
            TextViewHost.IsReadOnly = true;
            if (curWorkspace != null)
            {
                curWorkspace.Dispose();
            }

            this.curWorkspace = workspace;
        }