private async Task <TWidget> GetInstance <TWidget>(string widgetPath, UIMessage message, IWidgetFactory factory = null) where TWidget : Widget { if (PoolingWidgets.ContainsKey(widgetPath)) { var pool = PoolingWidgets[widgetPath]; if (pool.Count > 0) { var instance = pool.Pop(); return(instance as TWidget); } } if (factory == null) { factory = DefaultFactory; } TWidget widget; try { widget = (TWidget)await factory.CreateInstance(this, widgetPath, message); } catch (Exception e) { Her.Error(e); throw; } // mark widget factory FactoryLookup.Add(widget.ViewId, factory); return(widget); }
public object Convert(object fromObj, AdapterOptions options) { try { return(options.Convert(fromObj)); } catch (Exception e) { Her.Error(e); throw; } }