Monday, April 30, 2007
Been doing a little WCF today... I augmented a partial message class on a client with some additional properties, including this:

private bool _partOfResults = true;

 

public bool PartOfResults

{

    get { return _partOfResults; }

    set { _partOfResults = value; }

}


Now I assumed by default the any messages would have PartOfResults set to true... just like it used to work with ye olde XmlSerializer ;o)

But actually no ... WCF doesn't invoke the constructor - surprised I hadn't noticed until now - particularly annoying is of course my unit tests were passing because I was calling the default constructor on the message... so first of all I decided to cheat and just implement the method like this:

private bool _partOfResults;

 

public bool PartOfResults

{

    get { return !_partOfResults; }

    set { _partOfResults = !value; }

}


But I didn't like the implications ;o) so I went and actually looked up how to make it work properly:

[OnDeserialized]

private void InitializeExtraFields(StreamingContext context)

{

    _partOfResults = true;

}


Pretty boring ;o) just surprised me because I haven't done much WCF since it went final.
 | 
posted @ Monday, April 30, 2007 5:29:32 AM (New Zealand Standard Time, UTC+12:00)    Comments [0] | Trackback |
Comments are closed.
Search
FeedCount

Tags...
Who am I?
Alex Henderson
Alex Henderson
Auckland, New Zealand
Managing Director at Dev|Defined Limited

"Self Confessed Coding Junky for 15 years"
View Alex Henderson's profile on LinkedIn
 
Mobile: +64-21-402-969
Email: bittercoder 'at' gmail 'dot' com
MSN: bittercoder_nz@hotmail
Skype: alex.devdefined
Navigation