I am using c#,wpf and mvvm.
In my datagrid every row has in the last cell a ListBox with documents related to this row which I call a period.
The user can add documents to every period.
I want to display for every document the file type icon(16x16) and the document`s name.
The file type icon gives me a bit of a headache.
I am not sure wether I should save every documents file type icon like .DOC in the database because a day has maybe 10 periods each has 2 .DOC files attached thus I save 20 icons in the database which are 19 times redundant...
Most stuff my user will attach are Office file types like .xls,.doc,.pdf,images,zip/rar thats it I guess.
Another but technically more advanced would be to save the unique file type icon as encoded base-64 string in a XML file with the file type extension as key/value pair.
The xml is loaded one time in a dictionary one time at application start up
<FileTypes>
<Extension ext="doc" base64string="ff5598sdfusd98fjs9df98sd9f" />
<Extension ext="docx" base64string="ff5498sdfusd98fjs9df98sd9f" />
<Extension ext="xls" base64string="ff9548sdfdsfdfusd98fjs9df98sd9f" />
<Extension ext="xlsx" base64string="ff98sfdfddfusd98fjs9df98sd9f" />
<Extension ext="pdf" base64string="ff98fdfdsdfusd98fjs9df98sd9f" />
<Extension ext="zip" base64string="ff98dfdfsdfusd98fjs9df98sd9f" />
<Extension ext="rar" base64string="fffdf98sdfusd98fjs9df98sd9f" />
</FileTypes>
Every time a document comes down the database I check the file extension in the file name and retrieve the dictionary to get the base64 string for the file. I could still somehow implement a caching mechanism for the file type base64 string so I do not decode them every time I get a .doc file...
Maybe you have a quite different/better ? idea, please let me know or make suggestions about advantages/disadvantes of database/xml saving :)