Class with property that is a List Of items in a subclass - vb.net

I want a class for a Customer, with a text property name.
Another property CustAddress will be a list of multiple addresses.
Each address will have two string properties.
Here is what I have.
I am not sure if I need something in the constructor of the class address.
And I'm even not sure what the code would look like to exploit this class.
Also, I can't get the F11 Step Into debug feature to step into the class code. If i put a break in the class code it does break and works fine. I have modified the option "Just My Code" to remove checkbox, but it does not help. I have a solution containing one class module and one Windows App together.
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)>
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "c8e723b4-f229-4368-9737-97c4c71d490a"
Public Const InterfaceId As String = "16275ddb-5cfe-47c0-995f-84a5f868ad1b"
Public Const EventsId As String = "dad73a5c-8ac4-4384-a5f9-8e2c388b5514"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
'Fields
Private _name As String
Public _CustAddress As List(Of address)
'Constructor for class ComClass
Public Sub New()
_CustAddress = New List(Of address)
End Sub
Public Property CustName() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property
Public Property CustAddress() As List(Of address)
Get
Return _CustAddress
End Get
Set(value As List(Of address))
_CustAddress = value
End Set
End Property
Public Class address
Private _address1 As String
Private _address2 As String
Public Sub New()
'??????
End Sub
Public Property Address1 As String
Get
Return _address1
End Get
Set(value As String)
_address1 = value
End Set
End Property
Public Property Address2 As String
Get
Return _address2
End Get
Set(value As String)
_address2 = value
End Set
End Property
End Class
End Class

I took out the com stuff just to shorten the answer. Since you had no extra code in the Property Procedures I shortened that to automatic Properties. I also moved the address Class out on its own. This class could be useful else where in the program so a nested class is not really necessary.
Public Class ComClass1
Public Property CustName As String
Public Property CustAddress As List(Of address)
Public Sub New(cName As String, cAddresses As List(Of address))
CustName = cName
CustAddress = cAddresses
End Sub
End Class
Public Class address
Public Property Address1 As String 'Street Address
Public Property Address2 As String 'City and State
Public Sub New(a1 As String, a2 As String)
Address1 = a1
Address2 = a2
End Sub
End Class
Private Sub DeclareAComClass1()
Dim addrList As New List(Of address) From {
New address("12 Main Street", "Los Angeles, CA"),
New address("13 Park Avenue", "New York, NY")
}
Dim cc As New ComClass1("Big Company, Inc.", addrList)
End Sub

Here is what I have ended up with. #Mary got me further ahead. But because I am using a COM class, I can't have any public constructors with parameters.
I added a method called AddAddress which gives me the functionality I need.
In my original post I somehow left out MyBase.New which is required for a COM class.
I encourage comments with insights on this approach.
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)>
Public Class ComClass1
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "c8e723b4-f229-4368-9737-97c4c71d490a"
Public Const InterfaceId As String = "16275ddb-5cfe-47c0-995f-84a5f868ad1b"
Public Const EventsId As String = "dad73a5c-8ac4-4384-a5f9-8e2c388b5514"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
'Fields
Private _name As String
Private _CustAddress As List(Of address)
'Constructor for class ComClass
Public Sub New()
MyBase.New
_CustAddress = New List(Of address)
End Sub
Public Sub AddAddress(a1 As String, a2 As String)
Dim addr As New address(a1, a2)
_CustAddress.Add(addr)
End Sub
Public Property CustName() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property
Public Property CustAddress() As List(Of address)
Get
Return _CustAddress
End Get
Set(value As List(Of address))
_CustAddress = value
End Set
End Property
Public Class address
Private _address1 As String
Private _address2 As String
Public Sub New(a1 As String, a2 As String)
_address1 = a1
_address2 = a2
End Sub
Public Property Address1 As String
Get
Return _address1
End Get
Set(value As String)
_address1 = value
End Set
End Property
Public Property Address2 As String
Get
Return _address2
End Get
Set(value As String)
_address2 = value
End Set
End Property
End Class
End Class
And the code to implement/test is as follows:
Dim TestClass As New ComClass1
Dim myint As Int32
TestClass.CustName = "John Smith"
TestClass.AddAddress("123 Main Street", "Los Angeles")
TestClass.AddAddress("13 Park Avenue", "New York")
Debug.Print(TestClass.CustAddress(0).Address1) '123 Main Stree'
Debug.Print(TestClass.CustAddress(1).Address1) '13 Park Avenue
TestClass.CustAddress.Remove(TestClass.CustAddress(0))
Debug.Print(TestClass.CustAddress(0).Address1) ' 13 Park Avenue

Related

How to implement a class when it is defined in an interface?

An interface can have a class in it but I do not understand how to implement such an interface. I give an example below:
I wrote the following simple code without any interface:
Imports System
Module Program
Sub Main()
Dim n As New name("Mounisha", "Ghosh")
Dim student As New Student(n, 14)
Console.WriteLine("First Name: {0}", student.studentName.firstName)
Console.WriteLine("Last Name: {0}", student.studentName.lastName)
Console.WriteLine("Age: {0}", student.age)
Console.ReadLine()
End Sub
End Module
Class name
Public Property firstName As String
Public Property lastName As String
Sub New(ByVal f As String, ByVal l As String)
firstName = f
lastName = l
End Sub
End Class
Class Student
Private nameValue As name
Public ReadOnly Property studentName() As name
Get
Return nameValue
End Get
End Property
Public Property age As Integer
Sub New(ByVal n As name, ByVal a As Integer)
nameValue = n
age = a
End Sub
End Class
Then I tried to re-organize by putting the class name in an interface and implement it in the class student. But I was not able to construct my code. I give the overall idea of the code I am trying to construct below:
Imports System
Interface IClass
Class name
Public Property firstName As String
Public Property lastName As String
Sub New(ByVal f As String, ByVal l As String)
firstName = f
lastName = l
End Sub
End Class
End Interface
Module Program
Sub Main()
'How to create instances and pass values to constructors?
End Sub
End Module
Class Student : Implements IClass
'The idea is to create a readonly property of type "name"
'But not able to use the Interface to do the same
Public Property age As Integer
End Class
The main idea is to understand how to implement an interface with a class in it. Pls help.
The other point I want to highlight is that in the constructor of the class name I have written End Sub. Now we cannot use the end sub statement in interface - so why am I not getting an error? Also do the statements firstName = f and lastName = l not denote an implementation which should have been flagged as an error by the compiler - but not getting any error. Any explanations for this?
What you're doing is simply adding a nested class to the interface. This isn't seen as something that the implementing class has to implement but instead is just a class available via that interface. Using your structure, in order to require Student to implement a read only name property, you have to add that property to the interface.
Public Interface IClass
ReadOnly Property Fullname As Name
Class Name
Public Property FirstName As String
Public Property LastName As String
Sub New(firstName As String, lastName As String)
Me.FirstName = firstName
Me.LastName = lastName
End Sub
End Class
End Interface
Your Student Class would then look like
Public Class Student : Implements IClass
'Because Name is nested within IClass, it's referenced by IClass.Name
Public ReadOnly Property Fullname As IClass.Name Implements IClass.Fullname
Public Property Age As Integer
Public Sub New(name As IClass.Name, age As Integer)
Fullname = name
Me.Age = age
End Sub
End Class
And creating a student would be
Dim name = New IClass.Name("Mounisha", "Ghosh") 'again we access name via the interface
Dim student = New Student(name, 14)
Usually you would not add a nested Class to the interface but instead do something like
Module Program
Sub Main()
Dim studuent = New Student(New Name("Mounisha", "Ghosh"), 14)
End Sub
End Module
Interface IClass
ReadOnly Property Fullname As Name
End Interface
Public Class Name
Public Property FirstName As String
Public Property LastName As String
Sub New(firstName As String, lastName As String)
Me.FirstName = firstName
Me.LastName = lastName
End Sub
End Class
Class Student : Implements IClass
Public ReadOnly Property Fullname As Name Implements IClass.Fullname
Public Property Age As Integer
Public Sub New(name As Name, age As Integer)
Fullname = name
Me.Age = age
End Sub
End Class

How to create a class within a class in VBA

I am trying to create a class based off an existing set of data. The columns include name, street address, city, state, and zip. I would like to create a class with name and address. Within this class I would like to have another class for address containing street address, city, state and zip.
My code looks like this for each private variable (I do not have variables for city, state or zip but I am sure I need them):
Private pCustomerName As String
Public Property Let CustomerName(Value As String)
pCustomerName = Value
End Property
Public Property Get CustomerName() As String
CustomerName = pCustomerName
End Property
What would we be different about the address section to include a sub-class I guess is what I'm asking.
Currently looks like this:
Public Property Let Address(Value As String)
pAddress = Value
End Property
Public Property Get Address() As String
Address = pAddress
End Property
You are right there man! You can simply create another class for your address data and instantiate it inside your Customer Class. You just need to use VBA's Set keyword to assign the Address object back and forth. It is also usually good practice to instantiate the Address object in the Class_Initialize and set it to Nothing in the Class_Terminate as shown below:
Customer Class:
Option Explicit
Private pCustomerName As String
Private pAddress As AddressObj
Public Property Let CustomerName(value As String)
pCustomerName = value
End Property
Public Property Get CustomerName() As String
CustomerName = pCustomerName
End Property
Public Property Set CustomerAddress(value As AddressObj)
Set pAddress = value
End Property
Public Property Get CustomerAddress() As AddressObj
Set CustomerAddress = pAddress
End Property
Private Sub Class_Initialize()
Set pAddress = New AddressObj
End Sub
Private Sub Class_Terminate()
Set pAddress = Nothing
End Sub
Address Class (I called it AddressObj)
Option Explicit
Private pZipCode As Integer
Private pStreet As String
Private pState As String
Public Property Let ZipCode(value As Integer)
pZipCode = value
End Property
Public Property Get ZipCode() As Integer
ZipCode = pZipCode
End Property
Public Property Let Street(value As String)
pStreet = value
End Property
Public Property Get Street() As String
Street = pStreet
End Property
Public Property Let State(value As String)
pState = value
End Property
Public Property Get State() As String
State = pState
End Property
'... etc for other properties

Getting a property from the instantiator class

Not an experienced programmer, so probably not a hard question.
Developing a small application in VB.net in WPF.
I made 3 classes, EngineeringObject<==Inherits==PartOfInstallation<==Inherits==SensorActor
In the class SensorActor I'm trying to get a property of PartOfInstallation with the function MyBase.Name. But this goes directly to EngineeringObject. How do I solve this?
Public Class EngineeringObject
''Private declarations, alleen objecten die erven kunnen hieraan, of dmv van getters en setters
'Name of part
Private sName As String = "Naam"
'81346 Id's
Private sSystemId As String = "Functie" 'VentilationSystem, Pumpsystem
Private sLocationId As String = "Locatie" 'Room 0.0
Private sObjectId As String = "Object" 'Fan, Pump
'General
Private sPartNumber As String
Private sLinkToDatasheet As String
'Property's
Public Property Name() As String
Get
Return sName
End Get
Set(ByVal value As String)
sName = value
End Set
End Property
Public Property SystemId() As String
Get
Return sSystemId
End Get
Set(ByVal value As String)
sSystemId = value
End Set
End Property
Public Property PartNumber() As String
Get
Return sPartNumber
End Get
Set(ByVal value As String)
sPartNumber = value
End Set
End Property
Public Property LinkToDatasheet() As String
Get
Return sLinkToDatasheet
End Get
Set(ByVal value As String)
sLinkToDatasheet = value
End Set
End Property
Public Sub New()
End Sub
End Class
Public Class PartOfInstallation
Inherits EngineeringObject
'src: https://stackoverflow.com/questions/21308881/parent-creating-child-object
'src: https://stackoverflow.com/questions/16244548/how-to-create-a-list-of-parent-objects-where-each-parent-can-have-a-list-of-chil
Private lSensorActor As New List(Of SensorActor)
Public Function GetSensorActor()
Return Me.lSensorActor
End Function
Public Sub CreateSensorActor()
lSensorActor.Add(New SensorActor)
End Sub
End Class
Public Class SensorActor
Inherits PartOfInstallation
Dim sMyPartOfInstallation As String
Public Property MyPartOfInstallation As String
Get
Return sMyPartOfInstallation
End Get
Set(value As String)
sMyPartOfInstallation = MyBase.Name
End Set
End Property
End Class
If I understand it correctly, based on your comments, you want every SensorActor instantiated within a PartOfInstallation instance to get the same name as that instance.
If so, then just add a second constructor to your SensorActor class allowing you to pass a name for it as well:
Public Class SensorActor
Inherits PartOfInstallation
...your code...
Public Sub New() 'Empty constructor, for if/when you don't want to set the name immediately.
End Sub
Public Sub New(ByVal Name As String)
Me.Name = Name
End Sub
End Class
Now in your PartOfInstallation class you can do:
Public Sub CreateSensorActor()
lSensorActor.Add(New SensorActor(Me.Name)) 'Here, "Me" refers to the current PartOfInstallation instance.
End Sub
Alternatively you can make the SensorActor constructor take a PartOfInstallation instance instead, allowing you to copy any properties you like:
Public Class SensorActor
Inherits PartOfInstallation
...your code...
Public Sub New()
End Sub
Public Sub New(ByVal BasedOnPOI As PartOfInstallation)
Me.Name = BasedOnPOI.Name
End Sub
End Class
Thus making the code in the PartOfInstallation class:
Public Sub CreateSensorActor()
lSensorActor.Add(New SensorActor(Me))
End Sub
Read more about constructors: Object Lifetime: How Objects Are Created and Destroyed (Visual Basic) | Microsoft Docs
The result below, if there's room for improvement... always welcome.
SensorActor
Public Class SensorActor
Inherits PartOfInstallation
Dim sTemp As String
Public Overloads Property SystemId() As String
Get
Return Me.sSystemId
End Get
Set(ByVal value As String)
Me.sSystemId = sTemp + "." + value
End Set
End Property
Public Sub New(ByVal BasedOnPOI As PartOfInstallation)
sTemp = BasedOnPOI.SystemId
End Sub
End Class
PartOfInstallation
Public Class PartOfInstallation
Inherits EngineeringObject
'src: https://stackoverflow.com/questions/21308881/parent-creating-child-object
'src: https://stackoverflow.com/questions/16244548/how-to-create-a-list-of-parent-objects-where-each-parent-can-have-a-list-of-chil
Private lSensorActor As New List(Of SensorActor)
Public Function GetSensorActor()
Return Me.lSensorActor
End Function
Public Sub CreateSensorActor()
lSensorActor.Add(New SensorActor(Me))
End Sub
End Class
EngineeringObject
Public Class EngineeringObject
''Private declarations, alleen objecten die erven kunnen hieraan, of dmv van getters en setters
'Name of part
Private sName As String = "Naam"
'81346 Id's
Friend sSystemId As String = "Functie" 'VentilationSystem, Pumpsystem
Private sLocationId As String = "Locatie" 'Room 0.0
Private sObjectId As String = "Object" 'Fan, Pump
'General
Private sPartNumber As String
Private sLinkToDatasheet As String
'Property's
Public Property Name() As String
Get
Return sName
End Get
Set(ByVal value As String)
sName = value
End Set
End Property
Public Property SystemId() As String
Get
Return sSystemId
End Get
Set(ByVal value As String)
sSystemId = "=" + value
End Set
End Property
Public Property PartNumber() As String
Get
Return sPartNumber
End Get
Set(ByVal value As String)
sPartNumber = value
End Set
End Property
Public Property LinkToDatasheet() As String
Get
Return sLinkToDatasheet
End Get
Set(ByVal value As String)
sLinkToDatasheet = value
End Set
End Property
Public Sub New()
End Sub
End Class

Variable that automatically updates when another property is updated

I'm sure this is a very simple thing and there's just something I fundamentally don't understand about properties/variables. I want the class to have a variable that is assigned/calculated after some property values are input. This isn't homework, I'm just using a simplified example.
Public Class person
Public Property name As String
Public Property address As String
Public phoneNumber As String
Public Sub getPhoneNumber()
phoneNumber = lookLookThemUpInThePhoneBook
End Sub
End Class
I might not know the person's name AND address when they are created, but as soon as they are both assigned, I want the phone number to be calculated.
I know I could just do
Dim Eddy As New person
Eddy.name = "Ed Wood"
Eddy.address = "123 Sample Road"
Eddy.getPhoneNumber()
Debug.Print(Eddy.phoneNumber)
But this will get very cumbersome having to manually run the procedure, so I figure there has to be a way to have that value get proactively assigned.
I'd like to be able to do this
Eddy.name = "Ed Wood"
Eddy.address = "123 Sample Road"
Debug.Print(Eddy.phoneNumber) ' His phone number is just automatically looked up.
You can delay the phone number lookup until the phoneNumber property is referenced by implementing that logic in the setter of that property (as mentioned in the comments). Here is an example of that:
Public ReadOnly Property phoneNumber As String
Get
'Leverage a class level private variable and wrap in an
'If Statement if you only want To look it up once.
Return lookLookThemUpInThePhoneBook()
End Get
End Property
Then when you do objYourPerson.phoneNumber it does the look up for you.
Both the Name and Address properties can try to set the phone number when they are modified
Public Class Person
Private _name As String = ""
Private _address As String = ""
Private _phoneNumber As String = "not set yet..."
Public Property Name As String
Get
Return _name
End Get
Set(value As String)
_name = value
setPhoneNumber()
End Set
End Property
Public Property Address As String
Get
Return _address
End Get
Set(value As String)
_address = value
setPhoneNumber()
End Set
End Property
Public Property PhoneNumber As String
Get
Return _phoneNumber
End Get
Private Set(value As String)
_phoneNumber = value
End Set
End Property
Public Sub setPhoneNumber()
If Name <> "" AndAlso Address <> "" Then PhoneNumber = lookThemUpInThePhoneBook(Name, Address)
End Sub
Private Function lookThemUpInThePhoneBook(name As String, address As String) As String
Return "123456789" ' search by name and address here
End Function
End Class
usage:
Sub Main()
Dim Eddy As New Person()
Eddy.Name = "Ed Wood"
Console.WriteLine(Eddy.PhoneNumber)
Eddy.Address = "123 Sample Road"
Console.WriteLine(Eddy.PhoneNumber)
Console.ReadLine()
End Sub
output
not set yet...
123456789
something like this...
Public Class Person
Public Sub New(strname As String, straddress As String)
name = strname
address = straddress
_phoneNumber = LookThemUpInThePhoneBook(strname, straddress)
End Sub
Private Function LookThemUpInThePhoneBook(pName As String, pAddress As String) As String
Dim myPhone As String = ""
'Do work to look up phone number
Return myPhone
End Function
Private _phoneNumber As String
Public ReadOnly Property phoneNumber As String
Get
Return _phoneNumber
End Get
End Property
Private _name As String
Public Property name As String
Get
Return _name
End Get
Set(value As String)
_name = value
End Set
End Property
Private _address As String
Public Property address As String
Get
Return _address
End Get
Set(value As String)
_address = value
End Set
End Property
End Class
Then
Dim Eddy As New Person("Eddy wood", "123 Sample Road")
Debug.Print(Eddy.phoneNumber)

Class can't be used in WCF service, while derived class can

I have an abstract class FileFolderBase with 2 classes deriving from it File and Folder, the class ProjectFolder is again deriving from the Folder class.
I have a WCF service, called BrowseService with 2 functions: GetRoot, which returns a list of ProjectFolder instances, and OpenFolder, which returns one Folder instance.
Here's the service code
iBrowseService.vb:
Imports System.ServiceModel
<ServiceContract()>
Public Interface IBrowseService
<OperationContract()>
Function OpenFolder(ByVal path As String) As Domain.Folder
<OperationContract()>
Function GetRoot(ByVal projectCodes As String) As List(Of Domain.ProjectFolder)
End Interface
BrowseService.svc.vb:
Imports System.ServiceModel.Activation
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Public Class BrowseService
Implements IBrowseService
Public Function OpenFolder(ByVal path As String) As Domain.Folder Implements IBrowseService.OpenFolder
Dim service As MyService = New MyService()
Dim folder As Domain.Folder = service.OpenFolder(path)
Return folder
End Function
Public Function GetRoot(ByVal projectCodes As String) As List(Of Domain.ProjectFolder) Implements IBrowseService.GetRoot
Dim service As MyService = New MyService()
Dim folders As List(Of Domain.ProjectFolder)
If Not String.IsNullOrEmpty(projectCodes) Then
Dim codes As List(Of String) = projectCodes.Split(",").ToList
folders = service.GetRoot(codes)
Else
folders = service.GetRoot(Nothing)
End If
Return folders
End Function
End Class
Nothing overly complicated there, now the odd thing is, the GetRoot function works perfectly and returns a set of ProjectFolder instances when I call it. The OpenFolder function however, won't work at all. The WCF test client gives a 'This operation is not supported in the WCF Test Client cause it uses the type Folder' message and when I use the service in an application, I get a CommunicationsException, most inner exception message 'An existing connection was forcibly closed by the remote host', when invoking it.
I can't find any cause why ProjectFolder can be used, while Folder can't, especially cause ProjectFolder derives from Folder.
Here are the sources for the 4 type classes:
FileFolderBase
Imports System.Runtime.Serialization
<Serializable()>
<DataContract(IsReference:=True)>
Public MustInherit Class FileFolderBase
Implements IComparable(Of FileFolderBase)
#Region "Attributes"
Protected varPkey As Long
Protected varName As String
Protected varFullName As String
Protected varProjectFolder As ProjectFolder
Protected varLastModified As Date
#End Region
#Region "Properties"
<DataMember>
Public Property Pkey() As Long
Get
Return varPkey
End Get
Set(value As Long)
varPkey = value
End Set
End Property
<DataMember>
Public Property Name() As String
Get
Return varName
End Get
Set(ByVal value As String)
varName = value
End Set
End Property
<DataMember>
Public Property FullName() As String
Get
Return varFullName
End Get
Set(ByVal value As String)
varFullName = value
End Set
End Property
<DataMember>
Public Property ProjectFolder() As ProjectFolder
Get
Return varProjectFolder
End Get
Set(value As ProjectFolder)
varProjectFolder = value
End Set
End Property
<DataMember>
Public Property LastModified() As Date
Get
Return Me.varLastModified
End Get
Set(ByVal value As Date)
Me.varLastModified = value
End Set
End Property
#End Region
#Region "Methods"
'Equals function and = and <> operators
#End Region
#Region "CompareMethods"
'Comparison functions, used for sorting and stuff
#End Region
End Class
File
Imports System.Runtime.Serialization
<Serializable()>
<DataContract(IsReference:=True)>
Public Class File
Inherits FileFolderBase
#Region "Attributes"
Private varSize As Long
Private varComment As String
#End Region
#Region "Constructors"
Public Sub New()
Me.varPkey = 0
End Sub
Public Sub New(ByVal pkey As Long, ByVal name As String, ByVal fullName As String, ByVal lastModified As Date, ByVal size As Long, ByVal comment As String, ByVal project As ProjectFolder)
Me.varPkey = pkey
Me.varName = name
Me.varFullName = fullName
Me.varLastModified = lastModified
Me.varSize = size
Me.varComment = comment
Me.varProjectFolder = project
End Sub
#End Region
#Region "Properties"
<DataMember>
Public Property Size() As Long
Get
Return Me.varSize
End Get
Set(ByVal value As Long)
Me.varSize = value
End Set
End Property
<DataMember>
Public Property Comment() As String
Get
Return Me.varComment
End Get
Set(ByVal value As String)
Me.varComment = value
End Set
End Property
#End Region
#Region "Methods"
'Equals function and = and <> operators
#End Region
#Region "CompareMethods"
'Comparison functions, used for sorting and stuff
#End Region
End Class
Folder
Imports System.Runtime.Serialization
<Serializable()>
<DataContract(IsReference:=True)>
Public Class Folder
Inherits FileFolderBase
#Region "Attributes"
Protected varItems As List(Of FileFolderBase)
Protected varParent As Folder
#End Region
#Region "Constructors"
Public Sub New()
Me.varPkey = 0
End Sub
Public Sub New(ByVal pkey As Long, ByVal name As String, ByVal fullName As String, ByVal lastModified As Date, ByVal parent As Folder, ByVal project As ProjectFolder)
Me.varPkey = pkey
Me.varName = name
Me.varFullName = fullName
Me.varLastModified = lastModified
Me.varParent = parent
Me.varProjectFolder = project
varItems = New List(Of FileFolderBase)()
End Sub
#End Region
#Region "Properties"
<DataMember>
Public Property Items() As List(Of FileFolderBase)
Get
Return Me.varItems
End Get
Set(ByVal value As List(Of FileFolderBase))
Me.varItems = value
End Set
End Property
<DataMember>
Public Property Parent() As Folder
Get
Return varParent
End Get
Set(ByVal value As Folder)
Me.varParent = value
End Set
End Property
#End Region
#Region "Methods"
'Equals function and = and <> operators
#End Region
End Class
ProjectFolder
Imports System.Runtime.Serialization
<Serializable()>
<DataContract(IsReference:=True)>
Public Class ProjectFolder
Inherits Folder
#Region "Attributes"
Private varProject As Project
#End Region
#Region "Constructors"
Public Sub New()
MyBase.New()
End Sub
Public Sub New(ByVal project As Project, ByVal parent As Folder)
MyBase.New(0, project.Name, project.Name, Date.Now, parent, Nothing)
Me.varProject = project
End Sub
#End Region
#Region "Properties"
<DataMember>
Public Property Project() As Project
Get
Return Me.varProject
End Get
Set(ByVal value As Project)
Me.varProject = value
End Set
End Property
<DataMember>
Public Overloads Property Items() As List(Of FileFolderBase)
Get
Return Me.varItems
End Get
Set(ByVal value As List(Of FileFolderBase))
Me.varItems = value
End Set
End Property
<DataMember>
Public Overloads Property ProjectFolder() As ProjectFolder
Get
Return Me
End Get
Set(value As ProjectFolder)
End Set
End Property
#End Region
#Region "Methods"
'Equals function and = and <> operators
#End Region
End Class
Please help, cause I have no clue how this can be possible.