コード例 #1
0
        protected override bool LocalComputeJavascriptValue(IJavascriptObjectFactory factory)
        {
            if (JSValue != null)
                return false;

            JSValue = factory.CreateObject(true);
            JSValue.SetValue("CanExecuteValue", factory.CreateBool(_InitialCanExecute));
            JSValue.SetValue("CanExecuteCount", factory.CreateInt(_Count));
            return true;
        }
コード例 #2
0
        protected override bool LocalComputeJavascriptValue(IJavascriptObjectFactory factory)
        {
            if (JSValue != null)
            {
                return(false);
            }

            JSValue = factory.CreateObject(true);
            JSValue.SetValue("CanExecuteValue", factory.CreateBool(_InitialCanExecute));
            JSValue.SetValue("CanExecuteCount", factory.CreateInt(_Count));
            return(true);
        }
コード例 #3
0
        private JSGenericObject MappNested(object ifrom, IJavascriptObject resobject, JSGenericObject gres)
        {
            if (ifrom == null)
            {
                return(gres);
            }

            IEnumerable <PropertyInfo> propertyInfos = ifrom.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (PropertyInfo propertyInfo in propertyInfos.Where(p => p.CanRead))
            {
                string pn         = propertyInfo.Name;
                object childvalue = null;
                try
                {
                    childvalue = propertyInfo.GetValue(ifrom, null);
                }
                catch (Exception e)
                {
                    Trace.WriteLine(string.Format("MVVM for HTML: Unable to convert property {0} from {1} exception {2}", pn, ifrom, e));
                    continue;
                }

                IJSCSGlue childres = InternalMap(childvalue);

                _IWebView.Run(() => resobject.SetValue(pn, childres.JSValue));

                gres.Attributes[pn] = childres;
            }

            return(gres);
        }
コード例 #4
0
        private void MappNested(object from, IJavascriptObject resobject, JsGenericObject gres)
        {
            if (from == null)
            {
                return;
            }

            var propertyInfos = from.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanRead);

            foreach (var propertyInfo in propertyInfos)
            {
                var    propertyName = propertyInfo.Name;
                object childvalue;
                try
                {
                    childvalue = propertyInfo.GetValue(from, null);
                }
                catch (Exception e)
                {
                    _Logger.Info(() => $"Unable to convert property {propertyName} from {@from} exception {e}");
                    continue;
                }

                var childres = UnsafelMap(childvalue);
                _Context.WebView.Run(() => resobject.SetValue(propertyName, childres.JSValue));
                gres.UpdateCSharpProperty(propertyName, childres);
            }
        }
コード例 #5
0
ファイル: JSCommand.cs プロジェクト: yovannyr/MVVM.CEF.Glue
        public JSCommand(IWebView iCefV8Context, IDispatcher iUIDispatcher, ICommand icValue)
        {
            _UIDispatcher = iUIDispatcher;
            _IWebView     = iCefV8Context;
            _Command      = icValue;

            bool canexecute = true;

            try
            {
                canexecute = _Command.CanExecute(null);
            }
            catch { }

            JSValue = _IWebView.Evaluate(() =>
            {
                IJavascriptObject res = _IWebView.Factory.CreateObject(true);
                res.SetValue("CanExecuteValue", _IWebView.Factory.CreateBool(canexecute));
                res.SetValue("CanExecuteCount", _IWebView.Factory.CreateInt(_Count));
                return(res);
            });
        }
コード例 #6
0
 public void UpdateProperty(IJavascriptObject father, string propertyName, IJavascriptObject value)
 {
     _WebView.RunAsync(() =>
     {
         var silenter = GetOrCreateSilenter(father);
         if (silenter.IsUndefined)
         {
             _Logger.Info(() => $"UpdateProperty called during an injection process. Property updated {propertyName}");
             //may happen if code being call between register and inject
             //in this case just set attribute value. The value will be register after
             father.SetValue(propertyName, value);
             return;
         }
         var forProperty = silenter.GetValue(propertyName);
         forProperty.Invoke("silence", _WebView, value);
         InjectUnsafe(value);
     });
 }
コード例 #7
0
 public void UpdateProperty(IJavascriptObject father, string propertyName, IJavascriptObject value)
 {
     _WebView.RunAsync(() =>
     {
         var silenter = GetOrCreateSilenter(father);
         if (silenter.IsUndefined)
         {
             _Logger.Info(()=> $"UpdateProperty called during an injection process. Property updated {propertyName}");
             //may happen if code being call between register and inject
             //in this case just set attribute value. The value will be register after
             father.SetValue(propertyName, value);
             return;
         }
         var forProperty = silenter.GetValue(propertyName);
         forProperty.Invoke("silence", _WebView, value);
         InjectUnsafe(value);
     });
 }
コード例 #8
0
ファイル: VueExtractor.cs プロジェクト: skyclub66/Neutronium
 public void SetAttribute(IJavascriptObject father, string attibutename, IJavascriptObject value)
 {
     _WebView.Run(() => father.SetValue(attibutename, value));
 }
コード例 #9
0
        private JSGenericObject MappNested(object ifrom, IJavascriptObject resobject, JSGenericObject gres)
        {
            if (ifrom == null)
                return gres;

            IEnumerable<PropertyInfo> propertyInfos = ifrom.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (PropertyInfo propertyInfo in propertyInfos.Where(p => p.CanRead))
            {
                string pn = propertyInfo.Name;
                object childvalue = null;
                try
                {
                    childvalue = propertyInfo.GetValue(ifrom, null); 
                }
                catch(Exception e)
                {
                    Trace.WriteLine(string.Format("MVVM for HTML: Unable to convert property {0} from {1} exception {2}", pn, ifrom, e));
                    continue;
                }

                IJSCSGlue childres = InternalMap(childvalue);

                _IWebView.Run(() => resobject.SetValue(pn, childres.JSValue));

                gres.Attributes[pn] = childres;
            }

            return gres;
        }      
コード例 #10
0
ファイル: VueExtractor.cs プロジェクト: murugamsm/Neutronium
 public Task SetAttributeAsync(IJavascriptObject father, string attributeName, IJavascriptObject value)
 {
     return(_WebView.RunAsync(() => father.SetValue(attributeName, value)));
 }
コード例 #11
0
        private void MappNested(object from, IJavascriptObject resobject, JsGenericObject gres)
        {
            if (from == null)
                return;

           var propertyInfos = from.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(p => p.CanRead);

            foreach (var propertyInfo in propertyInfos)
            {
                var propertyName = propertyInfo.Name;
                object childvalue;
                try
                {
                    childvalue = propertyInfo.GetValue(from, null); 
                }
                catch(Exception e)
                {
                    _Logger.Info(()=> $"Unable to convert property {propertyName} from {@from} exception {e}");
                    continue;
                }

                var childres = UnsafelMap(childvalue);          
                _Context.WebView.Run(() => resobject.SetValue(propertyName, childres.JSValue));
                gres.UpdateCSharpProperty(propertyName, childres);
            }
        }
コード例 #12
0
 public void SetAttribute(IJavascriptObject father, string attibutename, IJavascriptObject value)
 {
     _WebView.Run(() => father.SetValue(attibutename, value));
 }