public override void Release(ViewComponent instance) { if (kernel.HasComponent(instance.GetType())) { kernel.ReleaseComponent(instance); } else { base.Release(instance); } }
/// <summary> /// Initialize the view component with mock services it needs to /// be functional. /// </summary> /// <param name="component">The component instance.</param> protected void PrepareViewComponent(ViewComponent component) { if (Context == null) { BuildEngineContext("", "Controller", "Action"); } viewEngine = BuildViewEngine(); componentContext = BuildViewComponentContext(component.GetType().Name); component.Init(Context, componentContext); }
public ViewComponentInfo(ViewComponent component) { Type = component.GetType(); Details = Type.GetCustomAttributes(typeof(ViewComponentDetailsAttribute), false).OfType<ViewComponentDetailsAttribute>().FirstOrDefault(); Instance = component; }