Форум: "Основная";
Текущий архив: 2002.07.15;
Скачать: [xml.tar.bz2];
ВнизPersistent.Assign??? Найти похожие ветки
← →
Freezer (2002-06-27 14:51) [0]глючит при присваивании свойств в методах Set... в сточках
if StrComp(FUserID, PChar(Value)) = 0 then
Exit;
TxpQueueItemConnect = class(TPersistent)
private
FDatabaseName: PChar;
FPassword: PChar;
FPropagate: Boolean;
FServerName: PChar;
FUserID: PChar;
function GetDatabaseName: String;
function GetPassword: String;
function GetServerName: String;
function GetUserID: String;
procedure SetDatabaseName(const Value: String);
procedure SetPassword(const Value: String);
procedure SetServerName(const Value: String);
procedure SetUserID(const Value: String);
protected
procedure EmptyPChar(var PC: PChar);
public
constructor Create;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property DatabaseName: String read GetDatabaseName write SetDatabaseName;
property Password: String read GetPassword write SetPassword;
property Propagate: Boolean read FPropagate write FPropagate;
property ServerName: String read GetServerName write SetServerName;
property UserID: String read GetUserID write SetUserID;
end;
{ TxpQueueItemConnect }
procedure TxpQueueItemConnect.Assign(Source: TPersistent);
begin
if Source is TxpQueueItemConnect then begin
DatabaseName := TxpQueueItemConnect(Source).DatabaseName;
Password := TxpQueueItemConnect(Source).Password;
Propagate := TxpQueueItemConnect(Source).Propagate;
ServerName := TxpQueueItemConnect(Source).ServerName;
UserID := TxpQueueItemConnect(Source).UserID;
end;
inherited Assign(Source);
end;
constructor TxpQueueItemConnect.Create;
begin
inherited Create;
{ set defaults }
FDatabaseName := nil;
FPassword := nil;
FPropagate := True;
FServerName := nil;
FUserID := nil;
end;
destructor TxpQueueItemConnect.Destroy;
begin
EmptyPChar(FDatabaseName);
EmptyPChar(FPassword);
EmptyPChar(FServerName);
EmptyPChar(FUserID);
inherited Destroy;
end;
procedure TxpQueueItemConnect.EmptyPChar(var PC: PChar);
begin
if PC <> nil then
StrDispose(PC);
end;
function TxpQueueItemConnect.GetDatabaseName: String;
begin
Result := FDatabaseName;
end;
function TxpQueueItemConnect.GetPassword: String;
begin
Result := FPassword;
end;
function TxpQueueItemConnect.GetServerName: String;
begin
Result := FServerName
end;
function TxpQueueItemConnect.GetUserID: String;
begin
Result := FUserID;
end;
procedure TxpQueueItemConnect.SetDatabaseName(const Value: String);
begin
if StrComp(FDatabaseName, PChar(Value)) = 0 then
Exit;
EmptyPChar(FDatabaseName);
GetMem(FDatabaseName, Length(Value) + 1);
StrPCopy(FDatabaseName, Value);
end;
procedure TxpQueueItemConnect.SetPassword(const Value: String);
begin
if StrComp(FPassword, PChar(Value)) = 0 then
Exit;
EmptyPChar(FPassword);
GetMem(FPassword, Length(Value) + 1);
StrPCopy(FPassword, Value);
end;
procedure TxpQueueItemConnect.SetServerName(const Value: String);
begin
if StrComp(FServerName, PChar(Value)) = 0 then
Exit;
EmptyPChar(FServerName);
GetMem(FServerName, Length(Value) + 1);
StrPCopy(FServerName, Value);
end;
procedure TxpQueueItemConnect.SetUserID(const Value: String);
begin
if StrComp(FUserID, PChar(Value)) = 0 then
Exit;
EmptyPChar(FUserID);
GetMem(FUserID, Length(Value) + 1);
StrPCopy(FUserID, Value);
end;
← →
Freezer (2002-06-27 15:41) [1]нужно ли вызывать inherided Assign(Source)? ведь он кроме вызова ошибки и вызова метода AssignTo() ничего не делает...
TxpQueueItemConnect = class(TPersistent)
private
FDatabaseName: String;
FPassword: String;
FPropagate: Boolean;
FServerName: String;
FUserID: String;
function GetDatabaseName: String;
function GetPassword: String;
function GetServerName: String;
function GetUserID: String;
procedure SetDatabaseName(const Value: String);
procedure SetPassword(const Value: String);
procedure SetServerName(const Value: String);
procedure SetUserID(const Value: String);
protected
public
constructor Create;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property DatabaseName: String read GetDatabaseName write SetDatabaseName;
property Password: String read GetPassword write SetPassword;
property Propagate: Boolean read FPropagate write FPropagate;
property ServerName: String read GetServerName write SetServerName;
property UserID: String read GetUserID write SetUserID;
end;
{ TxpQueueItemConnect }
procedure TxpQueueItemConnect.Assign(Source: TPersistent);
begin
if Source is TxpQueueItemConnect then begin
FDatabaseName := TxpQueueItemConnect(Source).DatabaseName;
FPassword := TxpQueueItemConnect(Source).Password;
FPropagate := TxpQueueItemConnect(Source).Propagate;
FServerName := TxpQueueItemConnect(Source).ServerName;
FUserID := TxpQueueItemConnect(Source).UserID;
end;
{ ошибка в след. строке}
inherited Assign(Source);
end;
← →
Игорь Шевченко (2002-06-27 15:44) [2].....
FUserID := TxpQueueItemConnect(Source).UserID;
end else
inherited Assign(Source);
С уважением,
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.07.15;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.011 c