LoadOnce Element (Data)
Context: HL Kit … Kit Reference … Data File Reference
The "loadonce" Element
The loadonce element has the following attributes:
key Key – Specifies a unique text key for the file. Only one file will ever be loaded for any given key.
If a "loadonce" element is found at the top of a file, the file is only parsed if another file with the same key has NOT been loaded. If a file with that key has already been loaded, the contents of the file are totally ignored.
If two or more files have the same loadonce element, exactly one of them will be loaded, with no guarantee of which one it will be. Don't assume anything about which file of a pair will be loaded - for example, on one computer, file A might be loaded and file B skipped, while on another computer file B might be loaded and file A skipped.
Please note: When choosing your key, make sure to choose something unique that won't be picked by anyone else! If you and someone else both use the same key, only one of your files will be loaded, which would cause problems that would be very hard to debug.
Example
If two files had the following loadonce elements, only a single one of them would be loaded:
File A: <loadonce key="John Smith's Source Definition File"/> File B: <loadonce key="John Smith's Source Definition File"/>
If four files had the following loadonce elements, file A would be loaded and only one of file B, C or D would also be loaded:
File A: <loadonce key="John Smith's Source Definition File"/> File B: <loadonce key="John Smith's Other Definition File"/> File C: <loadonce key="John Smith's Other Definition File"/> File D: <loadonce key="John Smith's Other Definition File"/>