Loading child languages from stream?

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by shark92651
Avatar
I have a need to load languages from a stream instead of from the xml file. The problem I am encountering is when a language contains child languages, the HTML language, for instance - an exception is raised that basically says I cannot do this. Is there ANY way that I can pre-load the child languages from stream or some other way to avoid this exception?

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Certainly... the following code creates a MemoryStream and writes the current language (and child languages) to it:
MemoryStream stream = new MemoryStream();
editor.Document.Language.SaveToXml(stream, 1);
This code reloads it:
stream.Position = 0;
editor.Document.Language = SyntaxLanguage.LoadFromXml(stream, 1);
I tried it on the HTML language and it worked fine.


Actipro Software Support

Posted 15 years ago by shark92651
Avatar
That only works once you have the original language(s) already loaded, which I do not. Here is the actual scenario I have:

I have the original XML file.
I have a set of changes I want to make to it.

I load the XML file into an XMLDocument object and then apply the changes.
I then write that XmlDocument out to a stream and then load that language from stream.

An error is raised because the language definition references child language files.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Try this, change the Secure flag in the languages (in the root tag) to false and load the HTML one. Then save it to a file using an encryption key of 0 (no encryption). We have a way to store multiple languages in a single file and when you do that you'll see it. Basically there is a root tag added to the XML to contain all the languages. If you mimic that, you should be able to do what you want.


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.