Please correct me if I've assumed something or misunderstood something.
Issue:
--------
When implementing the ReadInputFromCache the documentation instructs you to put the following line at the top of the \"Interface Code\":
- Code: Select all
DnpUtils.ReadInputFromCache(context);
and the following line at the top of the \"Template Code\":
- Code: Select all
DnpUtils.SaveInputToCache(context);
This works fine when running templates and generating code. I found that this gave me problems when working with Projects. Projects have their own settings so when you want change their settings you cannot edit them because the \"Record Template Input\" window always displays the last settings executed by the template. To work around this I have always executed the Project item before editing it to ensure the cached settings are correct.
Solution:
-----------
The solution is not to retrieve the settings from the cache when editing the Project item.
The only way I have found to do this is to check to see if the context.Gui.Defaults are already populated (by MyGeneration). If it is empty is indicates the template has been executed directly. If it contains items it indicates that it is a Project item.
So in the \"Interface Code\" instead of:
- Code: Select all
DnpUtils.ReadInputFromCache(context);
Use the following 2 lines:
- Code: Select all
if (context.Gui.Defaults.Count == 0)
DnpUtils.ReadInputFromCache(context);
------------------------
Please let me know if this helps anyone.
