 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
mee Guest
|
Posted: Thu Jun 15, 2006 2:33 pm Post subject: rename properties, properties alias |
|
|
Hi,
I try to convert a win32 application into DotNet (BDS2006).
I need to keep my source code still Win32 compatible.
I was using msXML in my application and I try now to use system.xml for
the DotNet version.
In have added a XML wrapper unit to my project with theses lines:
{$IFDEF WIN32}
wXMLDOMDocument = IXMLDOMDocument2;
wXMLDOMNode = IXMLDOMNode;
wXMLDOMNodeList = IXMLDOMNodeList;
{$ENDIF}
{$IFDEF CLR}
wXMLDOMDocument = XMLDocument;
wXMLDOMNode = XMLNode;
wXMLDOMNodeList = XMLNodeList;
{$ENDIF}
In the rest of the code I have replaced all occurences of
IXMLDOMDocument2, IXMLDOMNode and IXMLDOMNodeList with wXMLDOMDocument,
wXMLDOMNode and wXMLDOMNodeList.
The problem:
In system.XML, some properties have a different name than in the Win32
msXML version:
IXMLDOMNode.Text become XMLNode.InnerText
IXMLDOMNodeList.length become XMLNodeList.Count
IXMLDOMNodeList.Item[i] become XMLNodeList.Item(i)
What can I do in my XML wrapper unit to be able to use wXMLDOMNode.Text,
wXMLDOMNodeList.length,.. in the rest of my code ?
I have tried to write: Type wXMLDOMNode.Text = Type XMLNode.InnerText
but it didn't work.
Is there a way to rename a property of an existing object or to create a
kind of property alias ? |
|
| Back to top |
|
 |
Joanna Carter [TeamB] Guest
|
Posted: Thu Jun 15, 2006 3:16 pm Post subject: Re: rename properties, properties alias |
|
|
"mee" <b.eblin (AT) magic (DOT) fr> a écrit dans le message de news:
449129db$1 (AT) newsgroups (DOT) borland.com...
| I try to convert a win32 application into DotNet (BDS2006).
| I need to keep my source code still Win32 compatible.
This is not really the right group for this kind of question; I suggest you
try one of our groups with dotnet in the name.
FMPOV, it is not really possible to maintain single source code for Win32
and .NET, especially as you appear to be dealing with interfaces.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer |
|
| Back to top |
|
 |
Leonardo M. Ramé Guest
|
Posted: Thu Jun 15, 2006 8:30 pm Post subject: Re: rename properties, properties alias |
|
|
Mee,
you can create a unit for Win32 and other one for .Net and put the IFDEFs in the uses clause:
uses
{$IFDEF WIN32}
XMLWin32Unit,
{$ENDIF}
{$IFDEF CLR}
XMLDotNetUnit,
{$ENDIF}
Leonardo M. Ramé
http://leonardorame.blogspot.com
mee <b.eblin (AT) magic (DOT) fr> wrote:
| Quote: | Hi,
I try to convert a win32 application into DotNet (BDS2006).
I need to keep my source code still Win32 compatible.
I was using msXML in my application and I try now to use system.xml for
the DotNet version.
In have added a XML wrapper unit to my project with theses lines:
{$IFDEF WIN32}
wXMLDOMDocument = IXMLDOMDocument2;
wXMLDOMNode = IXMLDOMNode;
wXMLDOMNodeList = IXMLDOMNodeList;
{$ENDIF}
{$IFDEF CLR}
wXMLDOMDocument = XMLDocument;
wXMLDOMNode = XMLNode;
wXMLDOMNodeList = XMLNodeList;
{$ENDIF}
In the rest of the code I have replaced all occurences of
IXMLDOMDocument2, IXMLDOMNode and IXMLDOMNodeList with wXMLDOMDocument,
wXMLDOMNode and wXMLDOMNodeList.
The problem:
In system.XML, some properties have a different name than in the Win32
msXML version:
IXMLDOMNode.Text become XMLNode.InnerText
IXMLDOMNodeList.length become XMLNodeList.Count
IXMLDOMNodeList.Item[i] become XMLNodeList.Item(i)
What can I do in my XML wrapper unit to be able to use wXMLDOMNode.Text,
wXMLDOMNodeList.length,.. in the rest of my code ?
I have tried to write: Type wXMLDOMNode.Text = Type XMLNode.InnerText
but it didn't work.
Is there a way to rename a property of an existing object or to create a
kind of property alias ?
|
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Thu Jun 15, 2006 8:55 pm Post subject: Re: rename properties, properties alias |
|
|
mee wrote:
| Quote: | In system.XML, some properties have a different name than in the Win32
msXML version:
IXMLDOMNode.Text become XMLNode.InnerText
IXMLDOMNodeList.length become XMLNodeList.Count
IXMLDOMNodeList.Item[i] become XMLNodeList.Item(i)
What can I do in my XML wrapper unit to be able to use wXMLDOMNode.Text,
wXMLDOMNodeList.length,.. in the rest of my code ?
|
You could use class helpers on the .Net classes to add new properties to
them. Implement those properties by reading and writing the ones that
are already there. That should certainly work for turning Count into
Length. Turning Item() into Item[] may be trickier. You could instead
turn Item() into GetItem(), since the IXMLDOMNodeList interface must
have a public method backing the Item property, so call that instead of
using the property.
--
Rob |
|
| Back to top |
|
 |
mee Guest
|
Posted: Mon Jun 19, 2006 8:12 am Post subject: Re: rename properties, properties alias |
|
|
Rob Kennedy a écrit :
| Quote: |
You could use class helpers on the .Net classes to add new properties to
them. Implement those properties by reading and writing the ones that
are already there. That should certainly work for turning Count into
Length. Turning Item() into Item[] may be trickier. You could instead
turn Item() into GetItem(), since the IXMLDOMNodeList interface must
have a public method backing the Item property, so call that instead of
using the property.
|
Thank, I have used class helpers and its works (even for Item[]):
wHelperXMLDOMNodeList = class helper for wXMLDOMNodeList
private
function _GetItem(i: Integer): wXMLDOMNode;
function _GetCount: integer;
public
property Item[i: Integer] : wXMLDOMNode read _GetItem;
property length: integer read _GetCount;
end;
function wHelperXMLDOMNodeList._GetItem(i: Integer): wXMLDOMNode;
begin
if (i < 0) or (i > count-1) then
begin
result := nil;
exit;
end;
result := ItemOf[i];
end;
function wHelperXMLDOMNodeList._GetCount: integer;
begin
result := Count;
end;
function wHelperXMLDOMNode._GetText: string;
begin
Result := InnerText;
end;
procedure wHelperXMLDOMNode._SetText(const Buff: string);
begin
InnerText := Buff;
end; |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|