Table of Contents Previous Next
Logo
Client-Side Slice-to-C# Mapping : 14.14 Serializable Objects
Copyright © 2003-2010 ZeroC, Inc.

14.14 Serializable Objects

As discussed in Section 4.18, you can pass CLR serializable objects directly as operation parameters or as fields of another data type. For example:
["clr:serializable:SomeNamespace.CLRClass"]
sequence<byte> CLRObj;
struct MyStruct {
    int i;
    CLRObj o;
};

interface Example {
    void op(CLRObj o, MyStruct s);
};
The generated code for MyStruct contains member i of type int and a member o of type SomeNamespace.CLRClass:
public partial class MyStruct : _System.ICloneable {
    public int i;
    SomeNamespace.CLRClass o;

    // ...
}
Similarly, the signature for op has parameters of type CLRClass and MyStruct:
void op(SomeNamespace.CLRClass o, MyStruct s);
Of course, your client and server code must have an implementation of CLRClass that sets the Serializable attribute:
namespace SomeNamespace {
    [Serializable]
    public class CLRClass {
        // ...
    }
}
You can implement this class in any way you see fit—the Ice run time does not place any other requirements on the implementation. However, note that the CLR requires the class to reside in the same assembly for client and server.

Table of Contents Previous Next
Logo