Changeset 561 for PersistentData/UPDClient.pas
- Timestamp:
- Sep 10, 2022, 6:26:39 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
PersistentData/UPDClient.pas
r362 r561 1 1 unit UPDClient; 2 2 3 {$mode delphi}4 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, SpecializedList, SpecializedDictionary;6 Classes, SysUtils, Generics.Collections, UGenerics; 9 7 10 8 const … … 33 31 destructor Destroy; override; 34 32 procedure Assign(Source: TObjectProxy); 33 end; 34 35 { TObjectProxies } 36 37 TObjectProxies = class(TObjectList<TObjectProxy>) 38 function AddProxy: TObjectProxy; 35 39 end; 36 40 … … 59 63 ObjectName: string; 60 64 Path: string; 61 Objects: T ListObject; // TListObject<TObjectProxy>65 Objects: TObjectList<TObjectProxy>; 62 66 procedure Clear; 63 67 constructor Create; … … 74 78 end; 75 79 76 { TPDTypePropert yList}77 78 TPDTypePropert yList = class(TListObject)80 { TPDTypeProperties } 81 82 TPDTypeProperties = class(TObjectList<TPDTypeProperty>) 79 83 Client: TPDClient; 80 procedureAddSimple(Name: string; TypeName: string; Unique: Boolean = False;81 Index: Boolean = False) ;84 function AddSimple(Name: string; TypeName: string; Unique: Boolean = False; 85 Index: Boolean = False): TPDTypeProperty; 82 86 end; 83 87 … … 91 95 Name: string; 92 96 DbType: string; 93 Properties: TPDTypePropert yList;97 Properties: TPDTypeProperties; 94 98 function IsDefined: Boolean; 95 99 procedure Define; … … 100 104 end; 101 105 102 { TPDType List}103 104 TPDType List = class(TListObject)106 { TPDTypes } 107 108 TPDTypes = class(TObjectList<TPDType>) 105 109 Client: TPDClient; 106 110 function AddType(Name: string; DbType: string = ''): TPDType; … … 121 125 procedure SetConnectionString(AValue: string); virtual; 122 126 public 123 Types: TPDType List;127 Types: TPDTypes; 124 128 Version: string; 125 129 BackendName: string; … … 149 153 TPDClientClass = class of TPDClient; 150 154 151 152 153 154 155 155 resourcestring 156 SClientNotSet = 'Client not set'; 157 SNotSupported = 'Not supported'; 158 SVersionMismatch = 'Version mismatch, client: %0:s, server: %1:s. Please upgrade database.'; 159 SCantLoadObjectWithoutId = 'Can''t load object without id'; 156 160 157 161 158 162 implementation 159 163 160 { TPDTypePropertyList } 161 162 procedure TPDTypePropertyList.AddSimple(Name: string; TypeName: string; 163 Unique: Boolean; Index: Boolean); 164 var 165 NewProperty: TPDTypeProperty; 166 begin 167 NewProperty := TPDTypeProperty(AddNew(TPDTypeProperty.Create)); 168 NewProperty.Name := Name; 169 NewProperty.DbType := Client.Types.SearchByName(TypeName); 170 NewProperty.Unique := Unique; 171 NewProperty.Index := Index; 172 end; 173 174 175 { TPDTypeList } 176 177 function TPDTypeList.AddType(Name: string; DbType: string = ''): TPDType; 178 begin 179 Result := TPDType(AddNew(TPDType.Create)); 164 { TObjectProxies } 165 166 function TObjectProxies.AddProxy: TObjectProxy; 167 begin 168 Result := TObjectProxy.Create; 169 Add(Result); 170 end; 171 172 { TPDTypeProperties } 173 174 function TPDTypeProperties.AddSimple(Name: string; TypeName: string; 175 Unique: Boolean = False; Index: Boolean = False): TPDTypeProperty; 176 begin 177 Result := TPDTypeProperty.Create; 178 Result.Name := Name; 179 Result.DbType := Client.Types.SearchByName(TypeName); 180 Result.Unique := Unique; 181 Result.Index := Index; 182 Add(Result); 183 end; 184 185 { TPDTypes } 186 187 function TPDTypes.AddType(Name: string; DbType: string = ''): TPDType; 188 begin 189 Result := TPDType.Create; 180 190 Result.Client := Client; 181 191 Result.Name := Name; 182 192 Result.DbType := DbType; 183 end; 184 185 function TPDTypeList.SearchByName(Name: string): TPDType; 193 Add(Result); 194 end; 195 196 function TPDTypes.SearchByName(Name: string): TPDType; 186 197 var 187 198 I: Integer; … … 220 231 constructor TPDType.Create; 221 232 begin 222 Properties := TPDTypePropert yList.Create;233 Properties := TPDTypeProperties.Create; 223 234 end; 224 235 225 236 destructor TPDType.Destroy; 226 237 begin 227 Properties.Free;228 inherited Destroy;238 FreeAndNil(Properties); 239 inherited; 229 240 end; 230 241 … … 256 267 destructor TObjectProxy.Destroy; 257 268 begin 258 Properties.Free;259 inherited Destroy;269 FreeAndNil(Properties); 270 inherited; 260 271 end; 261 272 … … 282 293 begin 283 294 ColumnsFilter := TListString.Create; 284 Objects := T ListObject.Create;295 Objects := TObjectList<TObjectProxy>.Create; 285 296 end; 286 297 287 298 destructor TListProxy.Destroy; 288 299 begin 289 Objects.Free;290 ColumnsFilter.Free;291 inherited Destroy;300 FreeAndNil(Objects); 301 FreeAndNil(ColumnsFilter); 302 inherited; 292 303 end; 293 304 … … 313 324 procedure TPDClient.SetConnectionString(AValue: string); 314 325 begin 315 316 326 end; 317 327 … … 347 357 NewObject.Load; 348 358 349 DbVersion := NewObject.Properties. Values['Version'];359 DbVersion := NewObject.Properties.Items['Version']; 350 360 if Version <> DbVersion then 351 361 raise Exception.Create(Format(SVersionMismatch, [Version, DbVersion])); … … 397 407 Tables.Count := NewProxy.Objects.Count; 398 408 for I := 0 to NewProxy.Objects.Count - 1 do 399 Tables[I] := TObjectProxy(NewProxy.Objects[I]).Properties. Values['TABLE_NAME'];409 Tables[I] := TObjectProxy(NewProxy.Objects[I]).Properties.Items['TABLE_NAME']; 400 410 401 411 for I := 0 to Types.Count - 1 do … … 415 425 begin 416 426 inherited; 417 Types := TPDType List.Create;427 Types := TPDTypes.Create; 418 428 Types.Client := Self; 419 429 InitSystemTypes; … … 422 432 destructor TPDClient.Destroy; 423 433 begin 424 Types.Free;425 inherited Destroy;434 FreeAndNil(Types); 435 inherited; 426 436 end; 427 437 … … 436 446 procedure TPDClient.Install; 437 447 begin 438 439 448 end; 440 449 … … 446 455 procedure TPDClient.Update; 447 456 begin 448 449 457 end; 450 458
Note:
See TracChangeset
for help on using the changeset viewer.