// CORBA IDL
module demo { module unions { enum colorT{green,blue,red,black}; }; };
// C# e.g. : ColorT ColorTHelper
[Serializable] public class colorT : Org.Omg.CORBA.Portable.IDLEntity { /** * Enum member green value */ public const int _green = 0; /** * Enum member green */ public static colorT green { get { return new colorT(_green); } } /** * Enum member blue value */ public const int _blue = 1; /** * Enum member blue */ public static colorT blue { get { return new colorT(_blue); } } /** * Enum member red value */ public const int _red = 2; /** * Enum member red */ public static colorT red { get { return new colorT(_red); } } /** * Enum member black value */ public const int _black = 3; /** * Enum member black */ public static colorT black { get { return new colorT(_black); } } /** * Internal member value */ private int _colorT_value; /** * Private constructor * @param the enum value for this new member */ private colorT( int value ) { _colorT_value = value; } /** * Maintains singleton property for serialized enums. */ public System.Object ReadResolve() { return From_Int( Value() ); } /** * Return the internal member value * @return the member value */ public int Value() { return _colorT_value; } /** * Return a enum member from its value * @param an enum value * @return an enum member */ public static colorT From_Int(int value) { switch (value) { case 0 : return green; case 1 : return blue; case 2 : return red; case 3 : return black; } throw new Org.Omg.CORBA.BAD_OPERATION(); } /** * Return a string representation * @return a string representation of the enumeration */ public override string ToString() { switch (_colorT_value) { case 0 : return "green"; case 1 : return "blue"; case 2 : return "red"; case 3 : return "black"; } throw new Org.Omg.CORBA.BAD_OPERATION(); } } public class colorTHelper { /// /// Insert colorT into an any /// @param a an any /// @param t colorT value /// public static void Insert(Org.Omg.CORBA.Any a, demo.unions.colorT t ) { a.Type(Type()); Write(a.Create_Output_Stream(),t); } /// /// Extract colorT from an any /// @param a an any /// @return the extracted colorT value /// public static demo.unions.colorT Extract(Org.Omg.CORBA.Any a) { if (!a.Type().Equal(Type())) throw new Org.Omg.CORBA.MARSHAL(); return Read(a.Create_Input_Stream()); } /// /// Internal TypeCode value /// private static Org.Omg.CORBA.TypeCode _tc = null; /// /// Return the colorT TypeCode /// @return a TypeCode /// public static Org.Omg.CORBA.TypeCode Type() { if (_tc == null) { Org.Omg.CORBA.ORB orb = Org.Omg.CORBA.ORB.Init(); string[] _members = new string[4]; _members[0] = "green"; _members[1] = "blue"; _members[2] = "red"; _members[3] = "black"; _tc = orb.Create_Enum_TC(Id(),"colorT",_members); } return _tc; } /// /// Return the colorT IDL ID /// @return an ID /// public static string Id() { return _id; } private static string _id = "IDL:demo/unions/colorT:1.0"; /// /// Read colorT from a marshalled stream /// @param istream the input stream /// @return the readed colorT value /// public static demo.unions.colorT Read(Org.Omg.CORBA.Portable.InputStream istream) { return colorT.From_Int( (int) istream.Read_ULong()); } /// /// Write colorT into a marshalled stream /// @param ostream the output stream /// @param value colorT value /// public static void Write(Org.Omg.CORBA.Portable.OutputStream ostream, demo.unions.colorT value) { ostream.Write_ULong( (uint) value.Value()); } }