0.1.11.0: Cleaned up code formatting etc.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5409 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
gbamber
2016-12-04 18:31:18 +00:00
parent 1e944a1c58
commit 5cc6f902d0
8 changed files with 146 additions and 140 deletions

View File

@ -24,7 +24,7 @@
<UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/>
<MinorVersionNr Value="1"/>
<RevisionNr Value="10"/>
<RevisionNr Value="11"/>
<StringTable Comments="Buld configured for Win Linux and Darwin" FileDescription="An editor for OnlinePackageManager update JSON files" InternalName="jsoneditor" LegalCopyright="(c)2016 usernames lainz and minesadorada @ forum.lazarus.freepascal.org" LegalTrademarks="GPL code" OriginalFilename="jsoneditor" ProductName="Lazarus and Freepascal" ProductVersion="1.x and 3.x"/>
</VersionInfo>
<BuildModes Count="5">

View File

@ -10,7 +10,7 @@
<IsPartOfProject Value="True"/>
<EditorIndex Value="3"/>
<CursorPos Y="30"/>
<UsageCount Value="56"/>
<UsageCount Value="57"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -21,11 +21,11 @@
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="13"/>
<CursorPos X="62" Y="28"/>
<UsageCount Value="56"/>
<CursorPos X="44" Y="30"/>
<UsageCount Value="57"/>
<Bookmarks Count="2">
<Item0 Y="468" ID="1"/>
<Item1 X="8" Y="737"/>
<Item0 Y="457" ID="1"/>
<Item1 Y="727"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -33,7 +33,7 @@
<Unit2>
<Filename Value="ugenericcollection.pas"/>
<IsPartOfProject Value="True"/>
<UsageCount Value="56"/>
<UsageCount Value="57"/>
</Unit2>
<Unit3>
<Filename Value="D:\Lazarusprojects\golfml\egacalculator\source\umainform.pas"/>
@ -103,7 +103,7 @@
<EditorIndex Value="2"/>
<TopLine Value="10428"/>
<CursorPos X="29" Y="10452"/>
<UsageCount Value="11"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
@ -111,130 +111,130 @@
<EditorIndex Value="1"/>
<TopLine Value="517"/>
<CursorPos X="3" Y="478"/>
<UsageCount Value="11"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit12>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/>
<Caret Line="1395" Column="21" TopLine="1371"/>
<Caret Line="745" Column="27" TopLine="709"/>
</Position1>
<Position2>
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/>
<Caret Line="745" Column="27" TopLine="709"/>
<Caret Line="114" Column="3" TopLine="76"/>
</Position2>
<Position3>
<Filename Value="C:\NewPascalDarwin\lazarus\lcl\grids.pas"/>
<Caret Line="114" Column="3" TopLine="76"/>
<Filename Value="umain.pas"/>
<Caret Line="155" TopLine="134"/>
</Position3>
<Position4>
<Filename Value="umain.pas"/>
<Caret Line="155" TopLine="134"/>
<Caret Line="308" Column="3" TopLine="306"/>
</Position4>
<Position5>
<Filename Value="umain.pas"/>
<Caret Line="308" Column="3" TopLine="306"/>
<Caret Line="796" Column="19" TopLine="766"/>
</Position5>
<Position6>
<Filename Value="umain.pas"/>
<Caret Line="796" Column="19" TopLine="766"/>
<Caret Line="46" Column="40" TopLine="31"/>
</Position6>
<Position7>
<Filename Value="umain.pas"/>
<Caret Line="46" Column="40" TopLine="31"/>
</Position7>
<Position8>
<Filename Value="C:\NewPascalDarwin\fpc\rtl\objpas\classes\classesh.inc"/>
<Caret Line="498" Column="37" TopLine="465"/>
</Position7>
<Position8>
<Filename Value="umain.pas"/>
<Caret Line="450" Column="47" TopLine="426"/>
</Position8>
<Position9>
<Filename Value="umain.pas"/>
<Caret Line="450" Column="47" TopLine="426"/>
<Caret Line="298" Column="27" TopLine="285"/>
</Position9>
<Position10>
<Filename Value="umain.pas"/>
<Caret Line="298" Column="27" TopLine="285"/>
<Caret Line="313" Column="46" TopLine="290"/>
</Position10>
<Position11>
<Filename Value="umain.pas"/>
<Caret Line="313" Column="46" TopLine="290"/>
<Caret Line="316" Column="65" TopLine="293"/>
</Position11>
<Position12>
<Filename Value="umain.pas"/>
<Caret Line="316" Column="65" TopLine="293"/>
<Caret Line="313" Column="46" TopLine="289"/>
</Position12>
<Position13>
<Filename Value="umain.pas"/>
<Caret Line="313" Column="46" TopLine="289"/>
<Caret Line="320" TopLine="296"/>
</Position13>
<Position14>
<Filename Value="umain.pas"/>
<Caret Line="320" TopLine="296"/>
<Caret Line="310" Column="29" TopLine="295"/>
</Position14>
<Position15>
<Filename Value="umain.pas"/>
<Caret Line="310" Column="29" TopLine="295"/>
<Caret Line="672" Column="56" TopLine="635"/>
</Position15>
<Position16>
<Filename Value="umain.pas"/>
<Caret Line="672" Column="56" TopLine="635"/>
<Caret Line="810" Column="41" TopLine="787"/>
</Position16>
<Position17>
<Filename Value="umain.pas"/>
<Caret Line="810" Column="41" TopLine="787"/>
<Caret Line="812" Column="36" TopLine="786"/>
</Position17>
<Position18>
<Filename Value="umain.pas"/>
<Caret Line="812" Column="36" TopLine="786"/>
<Caret Line="813" Column="5" TopLine="790"/>
</Position18>
<Position19>
<Filename Value="umain.pas"/>
<Caret Line="813" Column="5" TopLine="790"/>
<Caret Line="811" TopLine="787"/>
</Position19>
<Position20>
<Filename Value="umain.pas"/>
<Caret Line="811" TopLine="787"/>
<Caret Line="814" Column="5" TopLine="787"/>
</Position20>
<Position21>
<Filename Value="umain.pas"/>
<Caret Line="814" Column="5" TopLine="787"/>
<Caret Line="812" Column="24" TopLine="784"/>
</Position21>
<Position22>
<Filename Value="umain.pas"/>
<Caret Line="812" Column="24" TopLine="784"/>
<Caret Line="811" Column="11" TopLine="788"/>
</Position22>
<Position23>
<Filename Value="umain.pas"/>
<Caret Line="811" Column="11" TopLine="788"/>
<Caret Line="813" Column="6" TopLine="789"/>
</Position23>
<Position24>
<Filename Value="umain.pas"/>
<Caret Line="813" Column="6" TopLine="789"/>
<Caret Line="489" TopLine="481"/>
</Position24>
<Position25>
<Filename Value="umain.pas"/>
<Caret Line="489" TopLine="481"/>
<Caret Line="819" TopLine="789"/>
</Position25>
<Position26>
<Filename Value="umain.pas"/>
<Caret Line="819" TopLine="789"/>
<Caret Line="813" TopLine="789"/>
</Position26>
<Position27>
<Filename Value="umain.pas"/>
<Caret Line="813" TopLine="789"/>
<Caret Line="79" Column="26" TopLine="50"/>
</Position27>
<Position28>
<Filename Value="umain.pas"/>
<Caret Line="79" Column="26" TopLine="50"/>
<Caret Line="812" TopLine="795"/>
</Position28>
<Position29>
<Filename Value="umain.pas"/>
<Caret Line="812" TopLine="795"/>
<Caret Line="735" Column="33" TopLine="720"/>
</Position29>
<Position30>
<Filename Value="umain.pas"/>
<Caret Line="735" Column="33" TopLine="720"/>
<Caret Line="683" TopLine="646"/>
</Position30>
</JumpHistory>
</ProjectSession>

View File

@ -303,6 +303,10 @@ msgstr "The .lpk entry #%d is is absent"
msgid "- There are no .lpk files in the list yet"
msgstr "- There are no .lpk files in the list yet"
#: umain.rsthereareoneo
msgid "- There are one or more .lpk entries with the same name.%s- Every .lpk entry must have a unique name."
msgstr ""
#: umain.rsthisoptionsh
msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?"
msgstr ""

View File

@ -122,6 +122,10 @@ msgstr "Archivos del Paquete"
msgid "Load..."
msgstr "Cargar..."
#: tfrmmain.mnu_filenew.caption
msgid "New"
msgstr ""
#: tfrmmain.mnu_filesave.caption
msgid "Save"
msgstr "Guardar"
@ -291,6 +295,10 @@ msgstr "La entrada .lpk #%d está ausente"
msgid "- There are no .lpk files in the list yet"
msgstr "- No hay ningún archivo .lpk en la lista todavía"
#: umain.rsthereareoneo
msgid "- There are one or more .lpk entries with the same name.%s- Every .lpk entry must have a unique name."
msgstr ""
#: umain.rsthisoptionsh
msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?"
msgstr "Esta opción debe ser usada solamente para actualizaciones cruciales o paquetes con arreglos de bugs. ¿Estás de acuerdo con esto?"
@ -330,3 +338,4 @@ msgstr "¿Quieres copiar %s a la carpeta %s?"
#: umain.rsyoumayneedto
msgid "(You may need to restart the app to see the change)"
msgstr "(Quizás necesites reiniciar la aplicación para ver los cambios)"

View File

@ -260,6 +260,10 @@ msgstr ""
msgid "- There are no .lpk files in the list yet"
msgstr ""
#: umain.rsthereareoneo
msgid "- There are one or more .lpk entries with the same name.%s- Every .lpk entry must have a unique name."
msgstr ""
#: umain.rsthisoptionsh
msgid "This option should only be used for crucial updates or bug-fixed packages. Are you OK with that?"
msgstr ""

View File

@ -42,7 +42,6 @@ object frmMain: TfrmMain
Width = 90
Caption = 'Force Update'
Color = clWindow
OnChange = cbForceUpdateChange
OnMouseUp = cbForceUpdateMouseUp
ParentColor = False
TabOrder = 1
@ -96,7 +95,6 @@ object frmMain: TfrmMain
RowCount = 1
TabOrder = 3
TitleStyle = tsNative
OnCellProcess = stringPackageFilesCellProcess
ColWidths = (
150
150
@ -131,7 +129,6 @@ object frmMain: TfrmMain
Caption = '&Close'
Kind = bkClose
ModalResult = 11
OnClick = cmd_CloseClick
TabOrder = 6
end
object cmd_save: TBitBtn

View File

@ -25,8 +25,9 @@ unit umain;
..to 0.1.6.0 Refactored and updated (minesadorada)
0.1.7.0: Bugfix (lainz)
0.1.8.0: Config file change (minesadorada)
0.1.9.0: Error check for duplicate lpk entries (minesadorada)
0.1.10.0: Exception handling for Load + Save (minesadorada)
Error check for duplicate lpk entries (minesadorada)
0.1.11.0: Cleaned up code formatting etc.
}
{$mode objfpc}{$H+}
@ -78,12 +79,13 @@ type
public
constructor Create;
destructor Destroy; override;
function LoadFromFile(AFileName: string):Boolean;
function LoadFromFile(AFileName: string): boolean;
function SaveToFile(AFileName: string): boolean;
published
property Package: TPackageData read FPackage write FPackage;
property PackageFiles: TPackageFilesList read FPackageFiles write FPackageFiles;
end;
{ TfrmMain }
TfrmMain = class(TForm)
@ -119,10 +121,8 @@ type
stringPackageFiles: TStringGrid;
procedure btnAddClick(Sender: TObject);
procedure btnRemoveClick(Sender: TObject);
procedure cbForceUpdateChange(Sender: TObject);
procedure cbForceUpdateMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
procedure cmd_CloseClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
@ -138,12 +138,10 @@ type
procedure SaveAsItemClick(Sender: TObject);
procedure sb_editNameClick(Sender: TObject);
procedure spd_CheckURLClick(Sender: TObject);
procedure stringPackageFilesCellProcess(Sender: TObject; aCol,
aRow: Integer; processType: TCellProcessType; var aValue: string);
private
{ private declarations }
JSONPackage: TPackage;
bForceSaveAs, bShowPopupHints, bDisableWarnings, bDirty,bIsVirgin: boolean;
bForceSaveAs, bShowPopupHints, bDisableWarnings, bDirty, bIsVirgin: boolean;
sJSONFilePath: string;
sUpdateDirectory, sZipDirectory: string;
CFG: TIniFile;
@ -153,7 +151,7 @@ type
procedure CtrlHidePopup(Sender: TObject);
procedure CtrlSetUpPopupHandlers;
procedure CtrlMakeDirty(Sender: TObject);
function IsADuplicateLPK:Boolean;
function FoundADuplicateLPK: boolean;
public
{ public declarations }
end;
@ -203,6 +201,8 @@ resourcestring
rsLanguageChan = 'Language changed to "%s".';
rsSorryThisLan = 'Sorry, this language is unavailable at this time.';
rsYouMayNeedTo = '(You may need to restart the app to see the change)';
rsThereAreOneO = '- There are one or more .lpk entries with the same name.%s'
+ '- Every .lpk entry must have a unique name.';
{ TPackageData }
@ -235,14 +235,16 @@ begin
exit;
MyPopup.Text := '';
MyPopup.Title := '';
If (Sender.InheritsFrom(TControl) = FALSE) then exit;
if (Sender.InheritsFrom(TControl) = False) then
exit;
myPopup.Text := TControl(Sender).Hint;
if (MyPopup.Text <> '') then
begin
mypopup.Title := rsHelpAndInfor;
mypopup.Text := mypopup.Text;
if bIsVirgin then mypopup.Text:=mypopup.Text + LineEnding + rsTurnHintsOff;
if bIsVirgin then
mypopup.Text := mypopup.Text + LineEnding + rsTurnHintsOff;
mypopup.showatpos(Mouse.CursorPos.X, Mouse.CursorPos.Y);
end;
end;
@ -256,7 +258,8 @@ begin
begin
for iCount := 0 to Pred(ControlCount) do
begin
If (Controls[iCount].InheritsFrom(TControl) = FALSE) then continue;
if (Controls[iCount].InheritsFrom(TControl) = False) then
continue;
if (Controls[iCount] is TEdit) then
begin
TEdit(Controls[iCount]).OnMouseEnter := @CtrlShowPopup;
@ -304,21 +307,21 @@ begin
end;
function TfrmMain.IsADuplicateLPK:Boolean;
Var
TempStringList:TStrings;
iCount:Integer;
function TfrmMain.FoundADuplicateLPK: boolean;
var
TempStringList: TStrings;
iCount: integer;
begin
Result:=FALSE;
TempStringList:=TstringList.Create;
TRY
For iCount:=0 to Pred(stringPackageFiles.RowCount) do
begin
If TempStringlist.IndexOf(stringPackageFiles.Cells[0,iCount]) = -1 then
TempStringList.Add(stringPackageFiles.Cells[0,iCount])
else
Result:=TRUE;
end;
Result := False;
TempStringList := TStringList.Create;
try
for iCount := 0 to Pred(stringPackageFiles.RowCount) do
begin
if TempStringlist.IndexOf(stringPackageFiles.Cells[0, iCount]) = -1 then
TempStringList.Add(stringPackageFiles.Cells[0, iCount])
else
Result := True;
end;
finally
TempStringList.Free;
end;
@ -335,11 +338,6 @@ begin
stringPackageFiles.RowCount := stringPackageFiles.RowCount - 1;
end;
procedure TfrmMain.cbForceUpdateChange(Sender: TObject);
begin
end;
procedure TfrmMain.cbForceUpdateMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
var
@ -355,11 +353,6 @@ begin
end;
end;
procedure TfrmMain.cmd_CloseClick(Sender: TObject);
begin
end;
procedure TfrmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CFG.WriteBool('Options', 'Virgin', False);
@ -369,7 +362,7 @@ end;
procedure TfrmMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
CanClose := True;
if bDisableWarnings = TRUE then
if bDisableWarnings = True then
exit;
if bDirty = True then
begin
@ -380,20 +373,20 @@ end;
procedure TfrmMain.FormCreate(Sender: TObject);
var
sLang,INIFilePath: string;
sLang, INIFilePath: string;
procedure CreateUniqueINI(aCount:Integer);
// Recursively loop until correct INI found, or new one created
begin
INIFilePath:=GetAppConfigFile(False) + IntToStr(aCount);
CFG := TIniFile.Create(INIFilePath);
If CFG.ReadString('Options','AppPath',ProgramDirectory) <> ProgramDirectory then
Begin
CFG.Free; // Ditch the old one
inc(aCount);
CreateUniqueINI(aCount); // Make a new one
procedure CreateUniqueINI(aCount: integer);
// Recursively loop until correct INI found, or new one created
begin
INIFilePath := GetAppConfigFile(False) + IntToStr(aCount);
CFG := TIniFile.Create(INIFilePath);
if CFG.ReadString('Options', 'AppPath', ProgramDirectory) <> ProgramDirectory then
begin
CFG.Free; // Ditch the old one
Inc(aCount);
CreateUniqueINI(aCount); // Make a new one
end;
end;
end;
begin
Self.AutoAdjustLayout(lapAutoAdjustForDPI, Self.DesignTimeDPI,
@ -422,10 +415,10 @@ begin
// If program location is different, create a new CFG file
// Because each component's location might be different
CreateUniqueINI(0);
CFG.WriteString('Options','AppPath',ProgramDirectory);
CFG.WriteString('Options', 'AppPath', ProgramDirectory);
// Pop-up hints (show on first run, then not again unless the user chooses)
bIsVirgin:=CFG.ReadBool('Options', 'Virgin', True);
bIsVirgin := CFG.ReadBool('Options', 'Virgin', True);
bShowPopupHints := bIsVirgin;
mnu_helpShowHints.Checked := bShowPopupHints;
// Override here if the user has re-enabled them
@ -463,25 +456,25 @@ begin
sJSONFilePath := FileOpen1.Dialog.Filename;
CFG.WriteString('Options', 'LastLoadedJSONPath', ExtractFileDir(sJSONFilePath));
JSONPackage := TPackage.Create;
TRY
if JSONPackage.LoadFromFile(FileOpen1.Dialog.FileName) then
begin
editName.Text := JSONPackage.Package.Name;
editDownloadURL.Text := JSONPackage.Package.DownloadURL;
cbForceUpdate.Checked := JSONPackage.Package.ForceUpdate;
stringPackageFiles.RowCount := JSONPackage.PackageFiles.Count + 1;
for i := 0 to JSONPackage.PackageFiles.Count - 1 do
try
if JSONPackage.LoadFromFile(FileOpen1.Dialog.FileName) then
begin
stringPackageFiles.Cells[0, i + 1] := JSONPackage.PackageFiles.Items[i].Name;
stringPackageFiles.Cells[1, i + 1] := JSONPackage.PackageFiles.Items[i].Version;
end;
end
else
ShowMessageFmt('There was a problem loading "%s" - is it corrupted or in the wrong format?',
[ExtractFilename(FileOpen1.Dialog.FileName)]);
editName.Text := JSONPackage.Package.Name;
editDownloadURL.Text := JSONPackage.Package.DownloadURL;
cbForceUpdate.Checked := JSONPackage.Package.ForceUpdate;
stringPackageFiles.RowCount := JSONPackage.PackageFiles.Count + 1;
for i := 0 to JSONPackage.PackageFiles.Count - 1 do
begin
stringPackageFiles.Cells[0, i + 1] := JSONPackage.PackageFiles.Items[i].Name;
stringPackageFiles.Cells[1, i + 1] := JSONPackage.PackageFiles.Items[i].Version;
end;
end
else
ShowMessageFmt('There was a problem loading "%s" - is it corrupted or in the wrong format?',
[ExtractFilename(FileOpen1.Dialog.FileName)]);
finally
JSONPackage.Free;
JSONPackage.Free;
end;
end;
end;
@ -490,10 +483,10 @@ procedure TfrmMain.mnu_fileNewClick(Sender: TObject);
begin
editname.Text := rsMypackagenam;
editDownloadURL.Text := rsHttpWwwUpdat;
cbForceUpdate.Checked:=False;
stringPackageFiles.RowCount:=1;
sJSONFilePath:='';
sZipDirectory:='';
cbForceUpdate.Checked := False;
stringPackageFiles.RowCount := 1;
sJSONFilePath := '';
sZipDirectory := '';
end;
procedure TfrmMain.mnu_fileSaveClick(Sender: TObject);
@ -675,11 +668,12 @@ begin
Result := True;
end;
end;
If IsADuplicateLPK then
// Check for duplicate .lpk entries
if FoundADuplicateLPK then
begin
stringPackageFiles.Color := clYellow;
slErrorList.Add('- There are one or more .lpk entries with the same name.'
+ LineEnding + '- Every .lpk entry must have a unique name.');
slErrorList.Add(Format(rsThereAreOneO, [LineEnding]));
Result := True;
end;
end;
@ -702,7 +696,7 @@ begin
if bForceSaveAs or (sJSONFilePath = '') then
begin
FileSaveAs1.Dialog.InitialDir := sUpdateDirectory;
FileSaveAs1.Dialog.FileName:='update_' + ExtractFilenameOnly(editName.text);
FileSaveAs1.Dialog.FileName := 'update_' + ExtractFilenameOnly(editName.Text);
if FileSaveAs1.Dialog.Execute then
sJSONFilePath := FileSaveAs1.Dialog.FileName
else
@ -723,7 +717,7 @@ begin
Version := stringPackageFiles.Cells[1, i];
end;
end;
if FileExistsUTF8(sJSONFilePath) AND (bDisableWarnings=FALSE) then
if FileExistsUTF8(sJSONFilePath) and (bDisableWarnings = False) then
begin
if MessageDlg(rsOverwrite + ' ' + sJSONFilePath + '?', mtConfirmation,
[mbYes, mbNo], 0, mbYes) = mrYes then
@ -781,11 +775,6 @@ begin
end;
end;
procedure TfrmMain.stringPackageFilesCellProcess(Sender: TObject; aCol,
aRow: Integer; processType: TCellProcessType; var aValue: string);
begin
end;
{ TPackage }
constructor TPackage.Create;
@ -805,22 +794,24 @@ begin
inherited Destroy;
end;
Function TPackage.LoadFromFile(AFileName: string):Boolean;
function TPackage.LoadFromFile(AFileName: string): boolean;
var
DeStreamer: TJSONDeStreamer;
s: TStringList;
begin
Result:=TRUE;
Result := True;
s := TStringList.Create;
TRY
s.LoadFromFile(AFileName);
DeStreamer := TJSONDeStreamer.Create(nil);
TRY
DeStreamer.JSONToObject(s.Text, Self);
EXCEPT
On E:Exception do Result:=FALSE;
end;
Finally
try
s.LoadFromFile(AFileName);
DeStreamer := TJSONDeStreamer.Create(nil);
try
DeStreamer.JSONToObject(s.Text, Self);
except
// Eat the exception
On E: Exception do
Result := False;
end;
finally
DeStreamer.Free;
s.Free;
end;
@ -831,7 +822,7 @@ var
Streamer: TJSONStreamer;
s: TStringList;
begin
Result := False;
Result := True;
s := TStringList.Create;
try
Streamer := TJSONStreamer.Create(nil);
@ -839,9 +830,10 @@ begin
s.AddText(Streamer.ObjectToJSONString(Self));
try
s.SaveToFile(AFileName);
Result := True;
except
// Eat the exception
On E: Exception do
Result := False;
end;
finally
Streamer.Free;