ROSLYN SOLUTION WITH STREAMS

Hello,
I want to integrate a scripting solution based on files saved in a database. Withing the IRoslynSolution interface I cannot find methods for adding documents/projects by stream (and not by filename). What to do?

Thanks,
Andreas
Hello Andreas,
You can use IRoslynRepository.AddDocument(string file, string text) method, where "file" parameter not necessary to be a real file, but only used for internal identification of source code from "text" parameter.
I've uploaded a small sample demonstrating this approach:
http://www.alternetsoft.com/forum/StreamDocument.zip
regards,
Andrew
Hello Andrew,
thank you very much for your fast answer. This leads me to another question: As far as I understand, the base elements of SyntaxEdit are the control itself, the TextSource and a (Roslyn)Parser. In my small project editor I have a list with the virtual source files and one SyntaxEdit. If I switch between the files, what is the best way to handle this? One SyntaxEdit, one Parser and one TextSource and loading the clicked file into the TextSource? Or one SyntaxEdit and one TextSource for each virtual source file and switching the TextSource? And do I need one parser for all files or one parser for each file?
Curious about your answer,
Andreas
Hello Andreas,
You can use one SyntaxEditor, one TextSoure and one Parser and reload editor content when switching between documents.
However internally it will only have one copy of Microsoft.CodeAnalysis.Document in Roslyn project, which will need to be updated every time you switch between documents (which will trigger re-parsing whole text loaded into SyntaxEdit), so most likely you will see the visual effect of code being re-parsed.
In case your text file are not completely independent (meaning that source a may use classes defined in source b), this approach will not quite work, as for features like code completion and error highlighting both documents will need to be loaded into the Roslyn project. In this case I would recommend to use as many TextSource/RoslynParser instances as many open documents you have. You might still be able to use single instance of SyntaxEdit and switch TextSource to show different content in it.
Hope this helps.
regards,
Andrew