public object ProvideValue(IServiceProvider serviceProvider) { var root = serviceProvider.GetService(typeof(IRootObjectProvider)) as IRootObjectProvider; var d = WAContext.GetImports(root.RootObject as Element); if (d.TryGetValue(Type, out Func <Element> f)) { return(f()); } throw new NotImplementedException(); }
public void SetImport(JSWrapper elementWrapper, string name, JSFunction factory) { var element = elementWrapper.As <Element>(); var d = WAContext.GetImports(element); if (d == null) { d = new Dictionary <string, Func <Element> >(); WAContext.SetImports(element, d); } d[name] = () => { var t = WAContext.GetAtomControl(element); var jv = factory.Call((JSObject)t.Wrap(Engine)) as JSValue; return(JSWrapper.FromKey(jv.ToObject().GetJSPropertyValue("element").ToString()).As <Element>()); }; }