I have two objects implemented as UserControls (compiled as separate DLLs). Both have implemented a specific property that is, in itself, an object. I need to pass this object between the two UserControls. Both of these internal properties are created separately and contain properties named the same and are typed the same. One, however is serializable, while the other is not. One contains two methods that the other does not. Otherwise each contain string properties that are, indeed, all the same.
VB.Net will not let me assign one to the other either directly or through TryCast without either a widening or narrowing conversion. I admit to not understanding what I should actually do in this conversion, so I am asking for some guidance. Here are my two properties:
First - the serializable one...
Expand|Select|Wrap|Line Numbers
- Public Class PanelInfo
- <XmlElement("sourceowner")> Public Property SourceOwner As New String(String.Empty)
- <XmlElement("locationname")> Public Property LocationName As New String(String.Empty)
- <XmlElement("description")> Public Property Description As New String(String.Empty)
- <XmlElement("secondarydescription")> Public Property SecondaryDescription As New String(String.Empty)
- <XmlElement("misc")> Public Property Misc As New String(String.Empty)
- <XmlElement("geolocation")> Public Property Geolocation As New GeolocationInfo_Type
- <XmlElement("copyright")> Public Property Copyright As New String(String.Empty)
- Private _CameraType As New String("unknown")
- <XmlElement("cameratype")> Public Property CameraType As String
- Get
- Return _CameraType
- End Get
- Set(value As String)
- Select Case value.ToLower
- Case "ptz"
- _CameraType = value
- Case "fixed"
- _CameraType = value
- Case "unknown"
- _CameraType = value
- Case Else
- _CameraType = "unknown"
- Throw New Exception("Only 'ptz', 'fixed' or 'unknown' are valid camera types")
- End Select
- End Set
- End Property
- Public Function XML() As String
- Using ser As New Serialization.Serializer
- Return ser.Obj2XML(Me, GetType(PanelInfo))
- End Using
- End Function
- Public Sub LoadXML(XML As String)
- Using ser As New Serialization.Serializer
- Dim This As PanelInfo = ser.XML2Obj(XML, GetType(PanelInfo))
- Me.SourceOwner = This.SourceOwner
- Me.LocationName = This.LocationName
- Me.Description = This.Description
- Me.SecondaryDescription = This.SecondaryDescription
- Me.Misc = This.Misc
- Me.Geolocation = This.Geolocation
- Me.Copyright = This.Copyright
- Me.CameraType = This.CameraType
- End Using
- End Sub
- End Class
- Public Class GeolocationInfo_Type
- <XmlAttribute("latitude")> Public Property Latitude As New String(String.Empty)
- <XmlAttribute("longitude")> Public Property Longitude As New String(String.Empty)
- <XmlAttribute("elevation")> Public Property Elevation As New String(String.Empty)
- End Class
Expand|Select|Wrap|Line Numbers
- Public Class PanelInfo
- Public Property SourceOwner As New String(String.Empty)
- Public Property LocationName As New String(String.Empty)
- Public Property Description As New String(String.Empty)
- Public Property SecondaryDescription As New String(String.Empty)
- Public Property Misc As New String(String.Empty)
- Public Property Geolocation As New Geolocation_Type
- Public Property Copyright As New String(String.Empty)
- Private _CameraType As New String("unknown")
- Public Property CameraType As String
- Get
- Return _CameraType
- End Get
- Set(value As String)
- Select Case value.ToLower
- Case "ptz"
- _CameraType = value
- Case "fixed"
- _CameraType = value
- Case "unknown"
- _CameraType = value
- Case Else
- _CameraType = "unknown"
- Throw New Exception("Only 'ptz', 'fixed' or 'unknown' are valid camera types")
- End Select
- End Set
- End Property
- Public Function XML() As String
- Throw New NotImplementedException("Not Implemented - non serializable class")
- End Function
- Public Sub LoadXML(XML As String)
- Throw New NotImplementedException("Not Implemented - non serializable class")
- End Sub
- End Class
- Public Class Geolocation_Type
- Public Property Latitude As New String(String.Empty)
- Public Property Longitude As New String(String.Empty)
- Public Property Elevation As New String(String.Empty)
- End Class
Any help would be greatly appreciated.