Пример #1
0
        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);
        }
Пример #2
0
 public object Convert(object fromObj, AdapterOptions options)
 {
     try { return(options.Convert(fromObj)); }
     catch (Exception e)
     {
         Her.Error(e);
         throw;
     }
 }