Exemplo n.º 1
0
        //public CefV8Value CreateDate(DateTime dt)
        //{
        //    return CefV8Value.CreateDate(dt);
        //}

        private CefV8Value UpdateObject(CefV8Value ires)
        {
            if (ires != null)
            {
                ires.SetValue("_MappedId", CefV8Value.CreateUInt(_MapCount++),
                    CefV8PropertyAttribute.ReadOnly | CefV8PropertyAttribute.DontEnum | CefV8PropertyAttribute.DontDelete);
            }

            return ires;
        }
Exemplo n.º 2
0
        public uint CreateAndGetID(CefV8Value iJSObject)
        {
            return _CefV8Context.Evaluate(() =>
            {
                var value = iJSObject.GetValue("_globalId_");
                if (value.IsUInt) return value.GetUIntValue();

                iJSObject.SetValue("_globalId_", CefV8Value.CreateUInt(++_Count), CefV8PropertyAttribute.DontDelete | CefV8PropertyAttribute.ReadOnly | CefV8PropertyAttribute.DontEnum);
                return _Count;
            });
        }
        private JSGenericObject MappNested(object ifrom, CefV8Value 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 awesomium: Unable to convert property {0} from {1} exception {2}", pn, ifrom, e));
                    continue;
                }

                IJSCSGlue childres = InternalMap(childvalue);

                _CefV8Context.Run(() => resobject.SetValue(pn, childres.JSValue, CefV8PropertyAttribute.None));

                gres.Attributes[pn] = childres;
            }

            return gres;
        }