e.g.
Node
NodeHelper
|
// VB
Imports System
Namespace demo.any
'
' Struct definition : Node
'
' @author TomORB VB Native Compiler 1.0rc1
'
<Serializable()> _
Public NotInheritable Class Node
Implements Org.Omg.CORBA.Portable.IDLEntity
'
' Struct member name
'
Public name As String
'
' Struct member _next
'
Public _next As demo.any.Node()
'
' Default constructor
'
Public Sub New()
End Sub
'
' Constructor with fields initialization
' @param name name struct member
' @param _next _next struct member
'
Public Sub New(name As String, _next As demo.any.Node())
Me.name = name
Me._next = _next
End Sub
End Class
End Namespace
Namespace demo.any
'
' Helper class for : Node
'
' @author TomORB VB Native Compiler 1.0rc1
'
Public Class NodeHelper
'
' Insert Node into an any
' param name="a" an any
' param name="t" Node value
'
Public Shared Sub Insert(a As Org.Omg.CORBA.Any, t As demo.any.Node)
a.Type(Type())
Write(a.Create_Output_Stream(),t)
End Sub
'
' Extract Node from an any
' @param a an any
' @return the extracted Node value
'
Public Shared Function Extract(a As Org.Omg.CORBA.Any) As demo.any.Node
If Not(a.Type().Equal(Type())) Then
Throw New Org.Omg.CORBA.MARSHAL()
End If
Return Read(a.Create_Input_Stream())
End Function
'
' Internal TypeCode value
'
Private Shared _tc As Org.Omg.CORBA.TypeCode = Nothing
Private Shared _working As Boolean = false
'
' Return the Node TypeCode
' @return a TypeCode
'
Public Shared Function Type() As Org.Omg.CORBA.TypeCode
If _tc Is Nothing Then
SyncLock (GetType(Org.Omg.CORBA.TypeCode))
If Not(_tc Is Nothing) Then
Return _tc
End If
If _working Then
Return Org.Omg.CORBA.ORB.Init().Create_Recursive_TC(Id())
End If
_working = True
Dim orb As Org.Omg.CORBA.ORB = Org.Omg.CORBA.ORB.Init()
Dim _members() As Org.Omg.CORBA.StructMember = New Org.Omg.CORBA.StructMember(1){}
_members(0) = New Org.Omg.CORBA.StructMember()
_members(0).name = "name"
_members(0).type = orb.Get_Primitive_TC(Org.Omg.CORBA.TCKind.tk_string)
_members(1) = New Org.Omg.CORBA.StructMember()
_members(1).name = "_next"
_members(1).type = orb.Create_Sequence_TC(Convert.ToUInt32(0) ,demo.any.NodeHelper.Type())
_tc = orb.Create_Struct_TC(Id(),"Node",_members)
_working = False
End SyncLock
End If
Return _tc
End Function
'
' Return the Node IDL ID
' @return an ID
'
Public Shared Function Id() As String
Return _id
End Function
Private Shared _id As String = "IDL:demo/any/Node:1.0"
'
' Read Node from a marshalled stream
' @param istream the input stream
' @return the readed Node value
'
Public Shared Function Read(istream As Org.Omg.CORBA.Portable.InputStream) As demo.any.Node
Dim new_one As demo.any.Node = New demo.any.Node()
new_one.name = istream.Read_String()
Dim size2 As Integer = Convert.ToInt32(istream.Read_ULong())-1
Dim tmp As demo.any.Node() = New demo.any.Node(size2){}
Dim i2 As Integer
For i2 = 0 To tmp.Length-1
tmp(i2) = demo.any.NodeHelper.Read(istream)
Next
new_one._next = tmp
Return new_one
End Function
'
' Write Node into a marshalled stream
' @param ostream the output stream
' @param value Node value
'
Public Shared Sub Write(ostream As Org.Omg.CORBA.Portable.OutputStream, value As demo.any.Node)
ostream.Write_String(value.name)
ostream.Write_ULong( Convert.ToUInt32(value._next.Length))
Dim i2 As Integer
For i2= 0 To value._next.Length-1
demo.any.NodeHelper.Write(ostream,value._next(i2))
Next
End Sub
End Class
End Namespace
|