Wednesday, June 17, 2009

"MGrammar" XAML Samples & Ultra Flexible Event Pattern Mesh Sample – my versions compatible with May CTP

There’re many samples which work with the newest “Oslo” May CTP on the Oslo Developer Center, but not all.  I’ve successfully tried to make my versions of two samples ("MGrammar" XAML Samples, Ultra Flexible Event Pattern Mesh Sample) compatible with new SDK . 

Running MWindow application in the first example was the most difficult thing.

You should change version of Xaml assembly from to otherwise you get exception at runtime.

File/assembly Class Method Line Code
MWindow.cs MWindow CreateLabelMap 92

var clrTypeResolverType = Type.GetType("System.Xaml.ClrTypeResolver, Xaml, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

MWindow.cs MWindow CreateLabelMap 96

var nsRecordType = Type.GetType("System.Xaml.ClrTypeResolver+XamlNamespaceRecord, Xaml, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

Old MGraph API still works,  but MGraphXamlReader produced bad nodes, so  bad XAML and bad tree of objects were generated. I debugged application and compared results with the program running with previous Oslo SDK on second computer. I detected code with different behavior:

File/assembly Class Method Line Code
ContentEntry.cs  ContentEntry


72 xamlReader.ReadToEnd()  
MGraphXamlReader.cs  MGraphXamlReader GetReader 434 GetNodes(this.root, true)
MGraphXamlReader.cs MGraphXamlReader GetNodes 343 if (this.graphBuilder.IsEntity(node))
GraphBuilder.cs MWindowGraph
IsEntity 299 EntityStencil.IsEntityBase(this, value)
System.Dataflow.dll EntityStencil IsEntityBase    

Method IsEntityBase in class EntityStencil has different implementation and returns now false for MWindow application nodes:

  • “Oslo” January SDK :  System.Dataflow.dll (  ->  EntityStencil.IsEntityBase –> true
  •   “Oslo” May SDK :  System.Dataflow.dll (  ->  EntityStencil.IsEntityBase –> false

When I created own IsEntityBase  method with old implementation and called it instead of  EntityStencil.IsEntityBase, MXamlReader produced good nodes as with previous SDK.

You can download my versions of samples compatible with new SDK below.

"MGrammar" XAML Samples

Ultra Flexible Event Pattern Mesh Sample

No comments: