e.g.
MyException
MyExceptionHelper
|
// C#
[Serializable]
public sealed class MyException : Org.Omg.CORBA.UserException
{
/**
* Exception member why
*/
public string why;
/**
* Default constructor
*/
public MyException() : base(MyExceptionHelper.Id())
{
}
/**
* Constructor with fields initialization
* @param why why exception member
*/
public MyException(string why) : base(MyExceptionHelper.Id())
{
this.why = why;
}
/**
* Full constructor with fields initialization
* @param why why exception member
*/
public MyException(string orb_reason, string why)
: base (MyExceptionHelper.Id() +" " + orb_reason)
{
this.why = why;
}
}
public class MyExceptionHelper
{
///
/// Insert MyException into an any
/// @param a an any
/// @param t MyException value
///
public static void Insert(Org.Omg.CORBA.Any a, demo.grid.MyServerPackage.MyException t )
{
a.Type(Type());
Write(a.Create_Output_Stream(),t);
}
///
/// Extract MyException from an any
/// @param a an any
/// @return the extracted MyException value
///
public static demo.grid.MyServerPackage.MyException 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;
private static bool _working = false;
///
/// Return the MyException 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.StructMember[] _members = new Org.Omg.CORBA.StructMember[1];
_members[0] = new Org.Omg.CORBA.StructMember();
_members[0].name = "why";
_members[0].type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string);
_tc = orb.Create_Exception_TC(Id(),"MyException",_members);
_working = false;
}
}
return _tc;
}
///
/// Return the MyException IDL ID
/// @return an ID
///
public static string Id()
{
return _id;
}
private static string _id = "IDL:demo/grid/MyServer/MyException:1.0";
///
/// Read MyException from a marshalled stream
/// @param istream the input stream
/// @return the readed MyException value
///
public static demo.grid.MyServerPackage.MyException Read(
Org.Omg.CORBA.Portable.InputStream istream)
{
demo.grid.MyServerPackage.MyException new_one =
new demo.grid.MyServerPackage.MyException();
if (!istream.Read_String().Equals(Id()))
throw new Org.Omg.CORBA.MARSHAL();
new_one.why = istream.Read_String();
return new_one;
}
///
/// Write MyException into a marshalled stream
/// @param ostream the output stream
/// @param value MyException value
///
public static void Write(Org.Omg.CORBA.Portable.OutputStream ostream,
demo.grid.MyServerPackage.MyException value)
{
ostream.Write_String(Id());
ostream.Write_String(value.why);
}
}
|