async Task <object> GetModelAsync(KasbahWebContext context, object properties, ComponentDefinition component, IPresentable content) { using (MiniProfiler.Current.Step(nameof(GetModelAsync))) { var asyncMethod = component.Control.GetMethod(nameof(ComponentBase <object> .GetModelAsync)); if (asyncMethod == null) { return(null); } dynamic instance = ActivatorUtilities.CreateInstance(_serviceProvider, component.Control); try { var task = (Task)asyncMethod.Invoke(instance, new object[] { context, properties, content }); await task.ConfigureAwait(false); return((object)((dynamic)task).Result); } finally { if (instance is IDisposable disposable) { disposable.Dispose(); } } } }
public async Task Invoke(HttpContext context) { var kasbahWebContext = new KasbahWebContext { WebApplication = _kasbahWebApplication, HttpContext = context, ContentService = _contentService, TypeRegistry = _typeRegistry, TypeMapper = _typeMapper, SiteRegistry = _siteRegistry }; context.Items[KasbahWebContext.Key] = kasbahWebContext; await _next.Invoke(context); }
public virtual object GetModel(KasbahWebContext context) { return(null); }
public virtual Task <TModel> GetModelAsync(KasbahWebContext context, TModel model, IPresentable content) => Task.FromResult(model);
public virtual Task <TModel> GetModelAsync(KasbahWebContext context, TProperties properties, IPresentable content) => Task.FromResult(default(TModel));