Posted 20 years ago
		by Marianne
	
In general, I have always found the SemanticParseData property unwieldy to work with.  In another thread you indicate that it can be used like a Tag property.  I have not found this to be the case.  In a very simple example if I try to do this in a SemanticParser:
I get a illegal implicit cast error... so I try an explicit cast:
But as you might guess I get a 'Cannot convert from type 'String' to type 'ISemanticParseData'.  So, I figure I'll try to cast the string to a generic object and then recast that to ISemanticParseData as such:
This example will compile but instead of a design-time error it waits until runtime to generate an exception.
In short, this is nothing like a Tag object because there seems to be no way to generate an appropriate object type in which to stuff into this ISemanticParseData interface. I know that a long time ago I had succeeded to make it work but ever since I haven't been able to recreate that magic. After searching the forums and the help, I don't see one example of how to actually populate the SemanticParseData of a Token with some data. Can you please explain it to those of us that aren't quite following at all what is happening here. Thank you.
[Modified at 03/05/2006 10:31 AM]
		            if (modification.HasFlag(DocumentModificationFlags.ProgrammaticTextParse))
            {
                // Collapse all outlining region nodes
                document.Outlining.RootNode.CollapseDescendants("Region");
                foreach (Token t in document.Tokens)
                {
                    if (t.Key == "MyToken")
                        t.SemanticParseData = document.GetTokenText(t);
                }
            }
t.SemanticParseData = (ISemanticParseData)document.GetTokenText(t);
t.SemanticParseData = (ISemanticParseData)(object)document.GetTokenText(t);
In short, this is nothing like a Tag object because there seems to be no way to generate an appropriate object type in which to stuff into this ISemanticParseData interface. I know that a long time ago I had succeeded to make it work but ever since I haven't been able to recreate that magic. After searching the forums and the help, I don't see one example of how to actually populate the SemanticParseData of a Token with some data. Can you please explain it to those of us that aren't quite following at all what is happening here. Thank you.
[Modified at 03/05/2006 10:31 AM]
------------------------------- Marianne