CORBA IDL enums will be simply mapped into their C# counterparts.
CORBA IDL unions will result in standard C# classes, since C# does not have variant structs (i.e. unions). The corresponding C# class contains a readonly 'discriminator' attribute which is initialized by the first writing access of one of its attributes.
Because a union is a complex data type (and will therefore be passed by value) a complete implementation of the IDL type is generated.
CORBA IDL enum <---> C# enum
CORBA IDL union <---> C# class
module UniEnu { enum property { surname, address, age, female}; union uniProperty switch (property) { case surname : string strSurname; case address : string strAddress; case age : long iAge; case female : boolean bFemale; }; interface Personal { void queryByName( in string strName, in property oPropIn, out uniProperty oPropOut); }; }; |
public class PersonalImpl: UniEnu.PersonalPOA { public override void queryByName( string a_strName, UniEnu.property a_oProp, out UniEnu.uniProperty a_oPropOut ) { a_oPropOut = new UniEnu.uniProperty(); switch( a_oProp ) { case UniEnu.property.surname: a_oPropOut.strSurname = a_strName + ", Dummy"; break; case UniEnu.property.address: a_oPropOut.strAddress = "Hamburg"; break; case UniEnu.property.age: a_oPropOut.iAge = 39; break; case UniEnu.property.female: a_oPropOut.bFemale = false; break; } } } |
UniEnu.uniProperty ouniProperty; for( UniEnu.property i = UniEnu.property.surname; i <= UniEnu.property.female; i++ ) { m_oPersonal.queryByName("Hans", i, out ouniProperty); switch( ouniProperty.discriminator) { case UniEnu.property.surname: System.Console.WriteLine("Surname:{0}", ouniProperty.strSurname); break; case UniEnu.property.address: System.Console.WriteLine("Address:{0}", ouniProperty.strAddress); break; case UniEnu.property.age: System.Console.WriteLine("Age:{0}", ouniProperty.iAge); break; case UniEnu.property.female: System.Console.WriteLine("Sex:{0}", (ouniProperty.bFemale ?"Female":"Male")); break; } } |
a.) Start the Server.
b.) Start the Client.