예제 #1
0
        public static void SetTime <TIndex>(this CefValue @this, DateTime value, TIndex index = default(TIndex))
        {
            SetTime(_ =>
            {
                var valueType = @this.GetValueType();
                switch (valueType)
                {
                case CefValueType.List:
                    using (var listValue = @this.GetList())
                    {
                        if (typeof(TIndex) == typeof(int))
                        {
                            listValue.SetBinary((int)Convert.ChangeType(index, typeof(int)), _);
                        }
                    }
                    break;

                case CefValueType.Dictionary:
                    using (var dictValue = @this.GetDictionary())
                    {
                        if (typeof(TIndex) == typeof(string))
                        {
                            dictValue.SetBinary((string)Convert.ChangeType(index, typeof(string)), _);
                        }
                    }
                    break;

                default:
                    @this.SetBinary(_);
                    break;
                }
            }, value);
        }
예제 #2
0
        internal unsafe static CefValue CastCefV8ValueToCefValue(CefV8Context context, CefV8Value value, out bool isXray)
        {
            isXray = false;
            if (value == null)
            {
                return(null);
            }

            if (!value.IsValid)
            {
                throw new InvalidCastException();
            }

            CefValue v;

            switch (value.Type)
            {
            case CefV8ValueType.Undefined:
                v = new CefValue();
                v.SetBinary(new byte[1]);
                return(v);

            case CefV8ValueType.Null:
                v = new CefValue();
                v.SetNull();
                return(v);

            case CefV8ValueType.Bool:
                v = new CefValue();
                v.SetBool(value.GetBoolValue());
                return(v);

            case CefV8ValueType.Int:                     // TYPE_INT, TYPE_UINT
            case CefV8ValueType.UInt:
                v = new CefValue();
                v.SetInt(value.GetIntValue());
                return(v);

            case CefV8ValueType.Double:
                v = new CefValue();
                v.SetDouble(value.GetDoubleValue());
                return(v);

            case CefV8ValueType.Date:
                v = new CefValue();
                v.SetBinary(XrayHandle.FromDateTime(value.GetDateValue().ToDateTime()).ToCfxBinaryValue());
                return(v);

            case CefV8ValueType.String:
                v = new CefValue();
                if (!value.CopyV8StringToCefValue(v))
                {
                    throw new CefRuntimeException("Can't copy the string.");
                }
                return(v);

            case CefV8ValueType.Object:
                isXray = true;
                if (value.IsArray)                         //TYPE_OBJECT (array)
                {
                    throw new NotImplementedException();
                }
                if (value.IsArrayBuffer)                         //TYPE_OBJECT (arraybuffer)
                {
                    throw new NotImplementedException();
                }
                v = new CefValue();
                v.SetBinary(XrayObject.Wrap(context, value).CreateHandle().ToCfxBinaryValue());
                return(v);
            }
            throw new NotImplementedException();
        }
예제 #3
0
 public static void SetTime(this CefValue @this, DateTime value)
 {
     SetTime(_ => @this.SetBinary(_), value);
 }
예제 #4
0
 public static void SetInt64(this CefValue @this, long value)
 {
     SetInt64(_ => @this.SetBinary(_), value);
 }