@@ -17,6 +17,8 @@ interface
1717
1818
1919uses
20+ // Delphi
21+ Generics.Collections,
2022 // Project
2123 UEncodings;
2224
@@ -89,10 +91,12 @@ TSourceFileInfo = class(TObject)
8991 var
9092 // / <summary>Stores information about the different source code output
9193 // types required by save source dialog boxes.</summary>
92- fFileTypeInfo: array [ TSourceFileType] of TSourceFileTypeInfo;
94+ fFileTypeInfo: TDictionary< TSourceFileType, TSourceFileTypeInfo> ;
9395 // <summary>Value of DefaultFileName property.</summary>
9496 fDefaultFileName: string;
9597 // / <summary>Read accessor for FileTypeInfo property.</summary>
98+ // / <exception>Raises <c>EListError</c> if <c>FileType</c> is not contained
99+ // / in the property.</exception>
96100 function GetFileTypeInfo (const FileType: TSourceFileType):
97101 TSourceFileTypeInfo;
98102 // / <summary>Write accessor for FileTypeInfo property.</summary>
@@ -103,11 +107,17 @@ TSourceFileInfo = class(TObject)
103107 // / necessary.</remarks>
104108 procedure SetDefaultFileName (const Value : string);
105109 public
110+ constructor Create;
111+ destructor Destroy; override;
112+
106113 // / <summary>Builds filter string for use in open / save dialog boxes from
107114 // / descriptions and file extensions of each supported file type.</summary>
108115 function FilterString : string;
109- // / <summary>Array of information about each supported file type that is
110- // / of use to save source dialog boxes.</summary>
116+ // / <summary>Information about each supported file type that is of use to
117+ // / save source dialog boxes.</summary>
118+ // / <exception>A <c>EListError</c> exception is raised if no information
119+ // / relating to <c>FileType</c> has been stored in this property.
120+ // / </exception>
111121 property FileTypeInfo[const FileType: TSourceFileType]: TSourceFileTypeInfo
112122 read GetFileTypeInfo write SetFileTypeInfo;
113123 // / <summary>Default source code file name.</summary>
@@ -130,6 +140,18 @@ implementation
130140
131141{ TSourceFileInfo }
132142
143+ constructor TSourceFileInfo.Create;
144+ begin
145+ inherited Create;
146+ fFileTypeInfo := TDictionary<TSourceFileType,TSourceFileTypeInfo>.Create;
147+ end ;
148+
149+ destructor TSourceFileInfo.Destroy;
150+ begin
151+ fFileTypeInfo.Free;
152+ inherited ;
153+ end ;
154+
133155function TSourceFileInfo.FilterString : string;
134156const
135157 cFilterFmt = ' %0:s (*%1:s)|*%1:s' ; // format string for creating file filter
@@ -139,6 +161,8 @@ function TSourceFileInfo.FilterString: string;
139161 Result := ' ' ;
140162 for FT := Low(TSourceFileType) to High(TSourceFileType) do
141163 begin
164+ if not fFileTypeInfo.ContainsKey(FT) then
165+ Continue;
142166 if Result <> ' ' then
143167 Result := Result + ' |' ;
144168 Result := Result + Format(
@@ -175,7 +199,10 @@ procedure TSourceFileInfo.SetDefaultFileName(const Value: string);
175199procedure TSourceFileInfo.SetFileTypeInfo (const FileType: TSourceFileType;
176200 const Info: TSourceFileTypeInfo);
177201begin
178- fFileTypeInfo[FileType] := Info;
202+ if fFileTypeInfo.ContainsKey(FileType) then
203+ fFileTypeInfo[FileType] := Info
204+ else
205+ fFileTypeInfo.Add(FileType, Info);
179206end ;
180207
181208{ TSourceFileTypeInfo }
0 commit comments