sanmaotuo_33@yahoo.com Guest
|
Posted: Sun Jan 07, 2007 10:43 am Post subject: How Can I Make an Assoctated Object Read-Only Really? |
|
|
I Have Designed 2 Interface in My Application: Bus & Driver. There is
an Associated Object(Interface) IBus in IDriver, Such as Below:
IBus = interface
{TGUID}
function GetCode: string;
procedure SetCode(const Value: string);
function GetBrand: string;
procedure SetBrand(const Value: string);
......
property Code: string read GetCode write SetCode;
property Brand: string read GetBrand write SetCode;
......
end;
IDriver = interface
{TGUID}
function GetID: string;
procedure SetID(const Value: string);
function GetName: string;
procedure SetName(const Value: string);
......
functuon GetBus: IBus;
property ID: string read GetID write SetID;
property Name: string read GetName write SetName;
......
property Bus: IBus read GetBus;
end;
TBus = class(TInterfacedObjec, IBus)
.....
end;
TDriver = class(TInterfacedObjec, IDriver)
.....
end;
When I Load Bus From Driver, I Can't Make Driver.Bus Read-only Really.
as I can write Bus.Code/Bus.Brand ALSO.
Driver.Bus.Code := 'xxxxxx';
Driver.Bus.Brand := 'xxxxxx';
Maybe I Should Hide THE BUS Back From Driver, Just Add IBus's Fields
into IDriver as Below:
IDriver = interface
{TGUID}
function GetID: string;
procedure SetID(const Value: string);
function GetName: string;
procedure SetName(const Value: string);
......
function GetCode: string;
function GetBrand: string;
property ID: string read GetID write SetID;
property Name: string read GetName write SetName;
......
property Code: string read GetCode;
property Brand: string read GetBrand;
end;
But I Don't Like This Way.
Is there a solution to meet my needing? |
|