Loading child languages from stream?

SyntaxEditor for Windows Forms Forum

Posted 19 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 19 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 19 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 19 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 (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.