Does anyone know how to convert the SerializationEntry line to ABL?
using (FileStream stream = new FileStream("Appearance.xml", FileMode.Open))
{
SoapFormatter formatter = new SoapFormatter();
formatter.Binder = new Binder();
ObjectStreamer streamer = formatter.Deserialize(stream) as ObjectStreamer;
this.ultraButton2.Appearance = ((SerializationEntry)streamer.Dictionary["Appearance"]).Value as AppearanceBase;
}
I tried the following but the last line does NOT compile.
DEFINE VARIABLE oFileStream AS CLASS System.IO.FileStream NO-UNDO.
DEFINE VARIABLE oSoapFormatter AS CLASS System.Runtime.Serialization.Formatters.Soap.SoapFormatter NO-UNDO.
DEFINE VARIABLE oObjectStreamer AS CLASS Infragistics.Shared.Serialization.ObjectStreamer NO-UNDO.
DEFINE VARIABLE oBinder AS CLASS Infragistics.Shared.Serialization.Binder NO-UNDO.
DEFINE VARIABLE oSerializationentry AS CLASS System.Runtime.Serialization.SerializationEntry NO-UNDO.
DEFINE VARIABLE oAppearanceBase AS CLASS Infragistics.Win.AppearanceBase NO-UNDO.
oFileStream =
NEW System.IO.FileStream ("Appearance.xml", FileMode:Open).
oSoapFormatter =
NEW System.Runtime.Serialization.Formatters.Soap.SoapFormatter ().
oBinder =
NEW Infragistics.Shared.Serialization.Binder ().
oSoapFormatter:Binder = oBinder.
oObjectStreamer =
NEW Infragistics.Shared.Serialization.ObjectStreamer ().
oObjectStreamer =
CAST (oSoapFormatter:Deserialize(oFileStream),Infragistics.Shared.Serialization.ObjectStreamer).
oSerializationEntry =
NEW System.Runtime.Serialization.SerializationEntry().
THIS-OBJECT:BtnFontDialog:Appearance = oSerializationEntry(oObjectStreamer:Dictionary["Appearance"]):Value.
The "as AppearanceBase" means you need to do another cast ...
CAST(oSerializationEntry(oObjectStreamer:Dictionary["Appearance"]):Value, AppearanceBase).
-- peter
Hmm, I tried that as well and still no compile. It complains about not understanding after “:Appearance =” (247)
THIS-OBJECT:BtnFontDialog:Appearance = CAST(oSerializationEntry(oObjectStreamer:Dictionary["Appearance"]):Value, Infragistics.Win.AppearanceBase).
Roger Blanchard
As a suggestion, when you run into code like this it is best to decompose it into reasonably short lines with no more than one colon (e.g. this:property, or this:function()) per line (or at least on the right side of an assignment). Doing this, you'll notice you are missing a cast.
In the original .net code you have:
this.ultraButton2.Appearance = ((SerializationEntry)streamer.Dictionary["Appearance"]).Value as AppearanceBase;
But your ABL is this which isn't the same:
THIS-OBJECT:BtnFontDialog:Appearance =
CAST(oSerializationEntry(oObjectStreamer:Dictionary["Appearance"]):Value,
Infragistics.Win.AppearanceBase).
oSerializationEntry is an object, but you're trying to treat it as a method.
Also, notice that the cast to SerializationEntry is around the the "Dictionary["Appearance"]" indexed property lookup; not around the "Dictionary["Appearance"]:Value" property reference.
There is also another cast to AppearanceBase of the "Value" property. You're missing a cast in the middle.
Try this:
define variable serializationEntry as SerializationEntry no-undo.
serializationEntry = cast(streamer:Dictionary["Appearance"], SerializationEntry).
THIS-OBJECT:ultraButton2:Appearance = cast(serializationEntry:Value, AppearanceBase).
Matt,
That works!! THANKS for the sample and suggestion. It is much appreciated.
Roger Blanchard