IDL Complex Type
stateful valuetype

The CORBA valuetype indicates that the method returns nothing.  It maps to C#'s class type.

Stateful valuetype is passed by value as arguments or result of remote methods.  Each stateful valuetype must be inherited from  Org.Omg.CORBA.Portable.StreamableValue and is marked with attribute Serializable.  The Serializable attribute is used for .Net streaming only, but not for Corba marshalling. 

Inheriated From Base Class:

Inherited From Interfaces:

Methods:

 

Constructors:

 

Fields:

 

Properties:

 

Repository ID:

 

// CORBA IDL
module demo
{
   module obv
   {
      module _valuetype
      {
         valuetype Account
         {
            private string name; 
            public string address;
            private float balance; 
   
            void debit(in float amount );
	
            void credit( in float amount);
            factory init( in string name, in string address, 
                          in float balance); 
         };
      };
   };
};
C#
					
[Serializable]
public abstract class Account : Org.Omg.CORBA.Portable.StreamableValue 
{
   ///
   /// Private member : name
   /// 
   protected string name; 
   
   ///
   /// Public member : address 
   /// 
   public string address;
    
   ///
   /// Private member : balance
   /// 
   protected float balance; 
   
   /**
   * Operation debit
   */ 
   public abstract void Debit(float amount); 
   
   /**
   * Operation credit 
   */
   public abstract void Credit(float amount);
   
   ///
   /// Return the truncatable ids
   ///
   static string[] _ids_list = { "IDL:demo/obv/valuetype/Account:1.0"}; 
   
   public virtual string[] _Truncatable_Ids() 
   {
      return _ids_list; 
   } 
   
   ///
   /// Unmarshal the value into an InputStream
   /// 
   public virtual void _Read(Org.Omg.CORBA.Portable.InputStream _is)
   {
      name = _is.Read_String();
      address = _is.Read_String();
      balance = _is.Read_Float(); 
   }

   ///
   /// Marshal the value into an OutputStream 
   ///
   public virtual void _Write(Org.Omg.CORBA.Portable.OutputStream os)
   {
      os.Write_String(name);
      os.Write_String(address); 
      os.Write_Float(balance);
   } 
   
   ///
   /// Return the value TypeCode
   /// 
   public virtual Org.Omg.CORBA.TypeCode _Type() 
   {
      return demo.obv.valuetype.AccountHelper.Type(); 
   }
}

public class AccountHelper
{ 
   /// 
   /// Insert Account into an any 
   /// @param a an any
   /// @param t Account value 
   ///
   public static void Insert(Org.Omg.CORBA.Any a, 
           demo.obv.valuetype.Account t) 
   { 
      a.Insert_Value(t, Type());
   }
      
   /// 
   /// Extract Account from an any 
   /// @param a an any 
   /// @return the extracted Account value 
   ///
   public static demo.obv.valuetype.Account Extract(
		Org.Omg.CORBA.Any a) 
   {
      if (!a.Type().Equal(Type())) 
         throw new Org.Omg.CORBA.MARSHAL();
      try 
      {
         return (demo.obv.valuetype.Account) 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;
      
   private static bool _working = false;
   
   ///
   /// Return the Account TypeCode
   /// @return a TypeCode 
   /// 
   public static Org.Omg.CORBA.TypeCode Type() 
   {
      if (_tc == null) 
      {
         lock (typeof(Org.Omg.CORBA.TypeCode))
         {
            if (_tc != null) 
               return _tc;
            if (_working) 
               return Org.Omg.CORBA.ORB.Init().Create_Recursive_TC(Id()); 
            _working = true; 
            Org.Omg.CORBA.ORB orb = Org.Omg.CORBA.ORB.Init(); 
            Org.Omg.CORBA.ValueMember[] _members = 
                             new Org.Omg.CORBA.ValueMember[3]; 
            _members[0] = new Org.Omg.CORBA.ValueMember(); 
            _members[0].name = "name"; 
            _members[0].type = 
                     orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string);
            _members[0].access = Org.Omg.CORBA.PRIVATE_MEMBER.value; 
            _members[1] = new Org.Omg.CORBA.ValueMember(); 
            _members[1].name = "address"; 
            _members[1].type  =  
                    orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string);
            _members[1].access = Org.Omg.CORBA.PUBLIC_MEMBER.value;
            _members[2] = new Org.Omg.CORBA.ValueMember();
            _members[2].name = "balance"; 
            _members[2].type = 
                   orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_float); 
            _members[2].access = Org.Omg.CORBA.PRIVATE_MEMBER.value; 
            Org.Omg.CORBA.TypeCode _concrete_tc = 
                orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_null); 
            _tc = orb.Create_Value_TC(Id(),"Account",Org.Omg.CORBA.VM_NONE.value,	
			         _concrete_tc,_members);
            _working = false;
         }
      }
      return _tc;
   }

   ///
   /// Return the Account IDL ID
   /// @return an ID
   ///
   public static string Id()
   {
      return _id;
   }

   private static string _id = "IDL:demo/obv/valuetype/Account:1.0";

   ///
   /// Read Account from a marshalled stream
   /// @param istream the input stream
   /// @return the readed Account value
   ///
   public static demo.obv.valuetype.Account Read(
                  Org.Omg.CORBA.Portable.InputStream istream)
   {
      return (demo.obv.valuetype.Account) ((Org.Omg.CORBA_2_3.Portable.InputStream) 
                istream).Read_Value(_id);
   }

   ///
   /// Write Account into a marshalled stream
   /// @param ostream the output stream
   /// @param value Account value
   ///
   public static void Write(Org.Omg.CORBA.Portable.OutputStream ostream, 
                     demo.obv.valuetype.Account value)
   {
      ((Org.Omg.CORBA_2_3.Portable.OutputStream)ostream).Write_Value(value, _id);
   }

   ///
   /// Create a value type (using factory method)
   ///
   public static Account Init(Org.Omg.CORBA.ORB orb, string name, string address, 
               float balance)
   {
      Org.Omg.CORBA.Portable.ValueFactory _factory = 
               ((Org.Omg.CORBA_2_3.ORB) orb).Lookup_Value_Factory(Id());
      if (_factory == null)
         throw new Org.Omg.CORBA.BAD_INV_ORDER();
      return ((demo.obv.valuetype.AccountValueFactory)(_factory)).Init(
               name,address,balance);
   }
}
	
public interface AccountValueFactory : Org.Omg.CORBA.Portable.ValueFactory
{
   ///
   /// Return the value type
   ///
   demo.obv.valuetype.Account Init(string name, string address, float balance);
}