IDL Complex Type | |
box valuetype |
The CORBA box valuetype (TBD) ...... It maps to C#'s class type. |
// CORBA IDL |
module demo { module obv { module valuebox { valuetype longBox long; }; }; }; |
e.g. longBox longBoxHelper |
// C# [Serializable] public class longBox : Org.Omg.CORBA.Portable.ValueBase { /** * Reference to the boxed value */ public int value; /** * Constructor * * @param initial the initial boxed value */ public longBox(int initial) { value = initial; } // // Return value box id // private static string[] _ids = { longBoxHelper.Id() }; /** * Return truncatable ids */ public string[] _Truncatable_Ids() { return _ids; } } public class longBoxHelper : Org.Omg.CORBA.Portable.BoxedValueHelper { /// /// Insert longBox into an any /// @param a an any /// @param t longBox value /// public static void Insert(Org.Omg.CORBA.Any a, demo.obv.valuebox.longBox t ) { a.Insert_Value(t, Type()); } /// /// Extract longBox from an any /// @param a an any /// @return the extracted longBox value /// public static demo.obv.valuebox.longBox Extract(Org.Omg.CORBA.Any a) { if (!a.Type().Equal(Type())) throw new Org.Omg.CORBA.MARSHAL(); try { return (demo.obv.valuebox.longBox)a.Extract_Value(); } catch (System.InvalidCastException e) { throw new Org.Omg.CORBA.MARSHAL(e.Message); } } /// /// Internal TypeCode value /// private static Org.Omg.CORBA.TypeCode _tc = null; /// /// Return the longBox TypeCode /// @return a TypeCode /// public static Org.Omg.CORBA.TypeCode Type() { if (_tc == null) { Org.Omg.CORBA.ORB orb = Org.Omg.CORBA.ORB.Init(); _tc = orb.Create_Value_Box_TC(Id(), "longBox",orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_long)); } return _tc; } /// /// Return the longBox IDL ID /// @return an ID /// public static string Id() { return _id; } private static string _id = "IDL:demo/obv/valuebox/longBox:1.0"; /// /// Read longBox from a marshalled stream /// @param istream the input stream /// @return the readed longBox value /// public static demo.obv.valuebox.longBox Read( Org.Omg.CORBA.Portable.InputStream istream) { return (demo.obv.valuebox.longBox) ((Org.Omg.CORBA_2_3.Portable.InputStream) istream).Read_Value(new demo.obv.valuebox.longBoxHelper()); } /// /// Write longBox into a marshalled stream /// @param ostream the output stream /// @param value longBox value /// public static void Write(Org.Omg.CORBA.Portable.OutputStream ostream, demo.obv.valuebox.longBox value) { ((Org.Omg.CORBA_2_3.Portable.OutputStream) ostream).Write_Value( value, new demo.obv.valuebox.longBoxHelper()); } /// /// Read a value from an input stream /// public System.Object Read_Value(Org.Omg.CORBA.Portable.InputStream _is) { demo.obv.valuebox.longBox _box = new demo.obv.valuebox.longBox((int)0); _box.value = _is.Read_Long(); return _box; } /// /// Write a value into an output stream /// public void Write_Value(Org.Omg.CORBA.Portable.OutputStream os, System.Object value) { longBox _box = (longBox)value; os.Write_Long(_box.value); } /// /// Return the value id /// public string Get_Id() { return Id(); } } |