P
paul perrin
I have a class I want to implement in VB.Net - but can't get the behaviour I
want.
There are two issues - one how should I be getting the behaviour I want, and
second is there a better way altogether?
1) How do I...
I have two classes, one represents a 'data record', the other is a generic
'data field'.
The data-field class has properties defining the position and datatype etc
of a datafield. It also provides a property that is intended to return the
value of that datafield from the data-record.
The data-record class has a property that acts a a buffer for a physical
data record, and a number of properties that are of type 'data-field' (as
described above).
ie (in pseudo code - to illustrate the idea)
class datarecord
private rec as xmldocument
public fld1 as datafield
public fld2 as datafield
end class
class datafield
public fieldtype as string
public fieldpath as string
public function value()
return <<parent>>.rec.selectsinglenode(fieldpath)
end function
end class
So I really want the xmldocument (rec) in an instance of the datarecord
class to be accessible to datafields of that class.The problems I have had
include - if the xmldocument is shared as part of the datafield class then
all datafields share it (not just the ones attached to a particular
datarecord), if the datafield is made a private class of the datarecord then
its properties cannot be accessed by calling programs.
2) A better way?
The main purpose of all this is to give programmers simple access to XML
data that gets validated at compile time rather than run time - am I missing
a trick?
Regards
Paul Perrin
/)/+)
Immediate Data Ltd
want.
There are two issues - one how should I be getting the behaviour I want, and
second is there a better way altogether?
1) How do I...
I have two classes, one represents a 'data record', the other is a generic
'data field'.
The data-field class has properties defining the position and datatype etc
of a datafield. It also provides a property that is intended to return the
value of that datafield from the data-record.
The data-record class has a property that acts a a buffer for a physical
data record, and a number of properties that are of type 'data-field' (as
described above).
ie (in pseudo code - to illustrate the idea)
class datarecord
private rec as xmldocument
public fld1 as datafield
public fld2 as datafield
end class
class datafield
public fieldtype as string
public fieldpath as string
public function value()
return <<parent>>.rec.selectsinglenode(fieldpath)
end function
end class
So I really want the xmldocument (rec) in an instance of the datarecord
class to be accessible to datafields of that class.The problems I have had
include - if the xmldocument is shared as part of the datafield class then
all datafields share it (not just the ones attached to a particular
datarecord), if the datafield is made a private class of the datarecord then
its properties cannot be accessed by calling programs.
2) A better way?
The main purpose of all this is to give programmers simple access to XML
data that gets validated at compile time rather than run time - am I missing
a trick?
Regards
Paul Perrin
/)/+)
Immediate Data Ltd