Changeset 3 for trunk/USource.pas
- Timestamp:
- Feb 2, 2011, 2:14:37 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 1 lib 2 2 FreePascalManager.exe 3 SourceList.xml 4 Config.xml
-
- Property svn:ignore
-
trunk/USource.pas
r2 r3 6 6 7 7 uses 8 Classes, SysUtils, Contnrs; 8 Classes, SysUtils, Contnrs, FileUtil, 9 DOM, XMLWrite, XMLRead, HTTPSend; 9 10 10 11 type 11 12 TSourceType = (stFPC, stIDE); 13 14 { TSource } 12 15 13 16 TSource = class … … 15 18 Name: string; 16 19 SubversionURL: string; 17 Version : string;18 V ariation: string;20 VersionNumber: string; 21 VersionType: string; 19 22 SourceType: TSourceType; 23 procedure Assign(Source: TSource); 20 24 end; 21 25 … … 24 28 TSourceList = class(TObjectList) 25 29 function FindById(Id: Integer): TSource; 30 procedure UpdateFormFile(FileName: string); 26 31 end; 27 32 28 33 implementation 34 35 { TSource } 36 37 procedure TSource.Assign(Source: TSource); 38 begin 39 Id := Source.Id; 40 Name := Source.Name; 41 VersionNumber := Source.VersionNumber; 42 VersionType := Source.VersionType; 43 SubversionURL := Source.SubversionURL; 44 SourceType := Source.SourceType; 45 end; 29 46 30 47 { TSourceList } … … 40 57 end; 41 58 59 procedure TSourceList.UpdateFormFile(FileName: string); 60 var 61 Doc: TXMLDocument; 62 NewNode: TDOMNode; 63 NewSubNode: TDOMNode; 64 I: Integer; 65 NewSource: TSource; 66 Child: TDOMNode; 67 ExistedSource: TSource; 68 begin 69 if FileExistsUTF8(FileName) then 70 try 71 ReadXMLFile(Doc, UTF8Decode(FileName)); 72 73 NewNode := Doc.DocumentElement.FindNode('Items'); 74 Child := NewNode.FirstChild; 75 while Assigned(Child) do 76 with Child do begin 77 try 78 NewSource := TSource.Create; 79 with NewSource do begin 80 NewSubNode := Child.FindNode('Name'); 81 if Assigned(NewSubNode) then 82 Name := UTF8Encode(string(NewSubNode.TextContent)); 83 NewSubNode := Child.FindNode('Id'); 84 if Assigned(NewSubNode) then 85 Id := StrToInt(NewSubNode.TextContent); 86 NewSubNode := Child.FindNode('SubversionURL'); 87 if Assigned(NewSubNode) then 88 SubversionURL := UTF8Encode(string(NewSubNode.TextContent)); 89 NewSubNode := Child.FindNode('VersionNumber'); 90 if Assigned(NewSubNode) then 91 VersionNumber := UTF8Encode(string(NewSubNode.TextContent)); 92 NewSubNode := Child.FindNode('VersionType'); 93 if Assigned(NewSubNode) then 94 VersionType := UTF8Encode(string(NewSubNode.TextContent)); 95 NewSubNode := Child.FindNode('SourceType'); 96 if Assigned(NewSubNode) then 97 SourceType := TSourceType(StrToInt(NewSubNode.TextContent)); 98 end; 99 ExistedSource := FindById(NewSource.Id); 100 if Assigned(ExistedSource) then begin 101 ExistedSource.Assign(NewSource); 102 end else begin 103 Add(NewSource); 104 FreeAndNil(NewSource); 105 end; 106 finally 107 NewSource.Free; 108 end; 109 Child := Child.NextSibling; 110 end; 111 finally 112 Doc.Free; 113 end; 114 end; 115 42 116 end. 43 117
Note:
See TracChangeset
for help on using the changeset viewer.