We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Create lexems on the fly

Hi,
I have the following problem: I'd like that users of my control based on Syncfusion.Edit could provide list of lexems dynamically (for example, list of the tables in the database). XML file would contain a template lexem for such table and I will create a copy of it, changing only BeginBlock entry.

What is the best way to create a copy of ConfigLexem (I suppose that shallow copy will be enough)? It is not support ICloneable and it's inconvenient to copy field by field.

Thanks in advance,
Olga

11 Replies

AD Administrator Syncfusion Team October 26, 2006 03:15 PM UTC

Hi Olga,

We are looking into this issue and will get back to you shortly.

Thanks for your patience.

Regards,
Manohari,


AD Administrator Syncfusion Team October 30, 2006 02:43 PM UTC

Hi Olga,

Our apologies for the delayed response. It is possible to copy lexems and change the BeginBlock alone using the Lexems.CopyTo() method. I have attached a sample that illustrates this in this link given below.

Sample



Please let me know if this meets your requirements.

Thanks for your patience.

Regards,
Manohari.R


AD Administrator Syncfusion Team October 31, 2006 09:08 AM UTC

No, your example is absolutely incorrect. You suggest copying the existing array of lexems into the other array. This array contains references to the same lexems. If you will look at the lexem in the first this.editControl1.Language.Lexems array, corresponding to the lexem, changed in the second array, you will see, that initial lexem has also been changed.
What I need, this is a creation of the absolutely new lexem, and copying to it all the fields from the existiong lexem.
The only possibility, I've found in your source code is to use serialization like that:
//serialize

XmlSerializer ser = new XmlSerializer(typeof(ConfigLexem));

ser.Serialize(stream, cfg);

//deserialize

XmlSerializer ser = new XmlSerializer(typeof(ConfigLexem));
stream.Seek(0, 0);
ConfigLexem res = (ConfigLexem) ser.Deserialize(stream);

res.ParentConfig = container;
res.UpdateSublexems();

res.BeginBlock = word;

Is there a better approach?


AD Administrator Syncfusion Team November 3, 2006 03:30 PM UTC

New status:
I refused to create new lexem for every table. Instead, I modify one lexem, setting regex expression with "or", i.e. Table1|Table2.

Config is processed rather frequently, but while trying to change text of the editor I have to wait about 5-8 seconds, while regexp will compile. The compilation is regulated by DEF_COMPILED_REGEX flag but I can't set up it outside of the editor.

Is there any possibility to compile regexps asyncroniosly or to cancel compilation?


OL Olga November 8, 2006 09:12 AM UTC

Hey, is anybody there?

I'll try to reformulate my question.
I want to use syntax coloring for tables from my database (there are about 1000 tables).

I've tried to add a new lexem for each table or create one lexem and use regular expression where all tables are enumerated using "or"

The second way works faster but in both cases when I try to type in (or insert programmatically) any text in the edit box, the reqular expressions start to compile and it takes 5-8 seconds).

How could I accellerate this process?
How can I color large set of objects quickly?
Any suggestions?


AD Administrator Syncfusion Team November 8, 2006 10:41 AM UTC

Hi Olga,

We regret very much for the delayed response. we are looking into this issue with ConfigLexem and will get back to you shortly.

Thanks for your patience.

Regards,
Manohari.R


AD Administrator Syncfusion Team November 13, 2006 12:26 PM UTC

Hi Olga,

We regret very much for the delayed response. Could you please let us know whether the table names using which lexems are to be created have any unique properties.

Thanks for your patience.

Regards,
Manohari.R


AD Administrator Syncfusion Team November 14, 2006 09:07 AM UTC

May be I don't understand your question, but their unique property is table name.


AD Administrator Syncfusion Team November 29, 2006 02:19 PM UTC

Hi Olga,

We regret vrey much for the delayed response. It is possible to create lexems at runtime using the this.editControl1.Language.Lexems.Add() method.

I have attached a sample that illustrates this in this link below.

Sample1

It is also possible to type text immediately in EditControl as soon as lexems are created without using regular expressions. I have attached a sample that creates 500 lexems in this link below.

Sample2.

Please let me know if this meets you requirements.

Thanks for your patience.

Regards,
Manohari.R


AD Administrator Syncfusion Team November 30, 2006 06:23 AM UTC

Thank you for your response.

I have not found .mdb file used in example.



AD Administrator Syncfusion Team November 30, 2006 06:44 AM UTC

Sorry for previous comment, this mdb is not necessary.

Well, yes. With 500 lexems it works acceptable - about 7 sec on my computer in debug build. But with 1000-2000 - it nearly hangs.

The only decision I can use here - add new lexems, for example, table, only when they are used in text. I have to parse text on load and monitor its changes :(

Loader.
Live Chat Icon For mobile
Up arrow icon