Example name: Property and field exclusion
Description: Demonstrates the use of WebORB's .NET attributes to exclude, from serialization from server to client, a given class' indicated data members (that is, fields and/or properties).
  • ExcludeProperty prevents the serialization of the indicated property; and
  • NonSerialized prevents the serialization of the indicated field.
Prerequisites:
Client-side code: Browse  Download
Server-side code: Browse  Download
Feature availability:
  • WebORB for .NET Development Mode
  • WebORB for .NET Community Edition
  • WebORB for .NET Enterprise Edition
Run example:
Key points:
  • When serializing an instance of a given server-side class to the client, WebORB serializes all of its public fields and properties. To exclude, from such serialization to the client, a given:
    • Field 'Foo': Decorate Foo's declaration with WebORB's [NonSerialized] attribute (see CreditScoreServer.cs, lines 31-32).
    • Property 'Bar': Decorate Bar's class' declaration with WebORB's [ExcludeProperty("Bar")] attribute (see CreditScoreServer.cs, lines 22 and 29).
  • In the sample application, the server-side code excludes the property 'SecretData' and the field 'SuperSecretData' from serialization to the client. Hence, Dr. Evil's aspirations of world domination, and monitoring by Austin Powers, are not exposed.
Things to try:
  • Make mistakes on purpose, such as attempting to exclude a private field, or excluding the same property twice, or placing the [ExcludeProperty] attribute on the property's declaration (rather than the class'), and so on.
See also:
Errata:
  • None yet known.