/// <summary> /// Reset the templates engine, if it is initialized but empty. /// </summary> /// <remarks> /// If an event as part of the add configuration code accesses templates, it can sometime happen, /// that the templates engine is started up, but without any templates in it. And it nevers resets. /// /// The symptom is that all items are displayed as "This item has no fields". /// </remarks> private void ResetTheTemplatesEngineIfTheTemplatesListIsEmpty(TemplateEngine templateEngine) { if (_hasResetTemplatesEngines) { return; } _hasResetTemplatesEngines = true; FieldInfo field = templateEngine.GetType().GetField("_templates", BindingFlags.NonPublic | BindingFlags.Instance); if (field == null) { return; } var templates = (TemplateDictionary)field.GetValue(templateEngine); if (templates != null && templates.Count == 0) { _log.Log <DataProviderMasterDatabase>("Resetting the template engine, because it is initialized but empty."); templateEngine.Reset(); } }