I'm looking for information or a sample of how to implementing a Formatter derived class. I would like to implement a custom formatter and would like to know how to make use of the Formatter class functionality.
Thanks,
Ray
I'm looking for information or a sample of how to implementing a Formatter derived class. I would like to implement a custom formatter and would like to know how to make use of the Formatter class functionality.
Thanks,
Ray
Formatter class implementation
Anvar
Thanks Vikram but I wasn't looking to implement IMessageFormatter. I want to implement a System.Runtime.Serialization.Formatter class and would like to know how to make use of the base class functionality. In particular I'd like to see the Schedule() and GetNext() methods in action as well as well as how to make use of the m_objectQueue during deserialization.
A couple other pieces to the puzzle are why does this class implement all the Write* routines I'm guessing they are there because there are helper routines somewhere that makes use of these functions by iterating through the serializable fields and it's likely that is the bit of code that enforces the serialization rules but where is that functionality I suspect you call GetNext() and send the returned object to that code for serialization and it in turn calls the Serialization.Formatter.
Thanks,
Ray
toypaj
I guess the only option for you then would be to go through the source code of the .NET Framework [ROTOR].
Take look at the implementation of the Formatter Class.
http://dotnet.di.unipi.it/Content/sscli/docs/doxygen/fx/bcl/classSerialization_1_1Formatter.html
Hope this helps.
Regards,
Vikram
SCHRANK
Here's a very good KB article that covers this concept:
How to create a custom message formatter by using Visual C# .NET
http://support.microsoft.com/default.aspx scid=kb;EN-US;310683
Regards,
Vikram
bobberino1
Regards,
Joannes
JenLS
Obviously the person who wrote the gotdotnet sample was aware of the Formatter class since he implemented his own queue and used the same function names as the Formatter class. My guess is that he was also not able to find information on how to make use of the Formatter class.
Perhaps a bit more detail about the glue I'm missing is in order (pseudo code):
class MyFormatter: Formatter
{
Serialize(object o)
{
Schedule(o);
While(o = GetNext())
{
// something goes here that iterates the object members and
// calls the appropriate Formatter.Write* routines and places
// object references in the queue. My belief is that some helper
// takes my formatter object and implements that functionality
// calling my Formatter.Write* routines as needed while enforcing
// serialization rules -- what/where is it If such a helper does not,
// exist, then Formatter class is nothing more than a named queue and
// really provides little to no functionality.
}
}
Deserialize()
{
// what goes here to reconstruct the references , Formatter contains
// contains the Write* routines, is there another object that is supposed
// to provide an interface to a set of Read* routines that I would
// implement
}
}
Thanks,
Ray
Viktor Placek
Here you go: Sample from Gotdotnet:
http://www.gotdotnet.com/Community/UserSamples/Details.aspx SampleGuid=22fdf161-5e3b-4586-a908-4f55082623b3
Regards,
Vikram