Example #1
0
        static CefV8Value InternalToV8Value(ClrToV8ConversionKind convKind, object value)
        {
            switch (convKind)
            {
            case ClrToV8ConversionKind.FromOpaqueObject:

                break;

            case ClrToV8ConversionKind.FromObject:
                if (value == null)
                {
                    return(CefV8Value.CreateNull());
                }
                else
                {
                    //get actual type of the value
                    ClrToV8ConversionKind actualConv;
                    return(((actualConv = GetConvKind(value.GetType())) == ClrToV8ConversionKind.FromObject) ?
                           InternalToV8Value(ClrToV8ConversionKind.FromOpaqueObject, value) :
                           InternalToV8Value(actualConv, value));
                }

            case ClrToV8ConversionKind.FromString:
                return(CefV8Value.CreateString((string)value));

            case ClrToV8ConversionKind.FromDouble:
                return(CefV8Value.CreateDouble((double)value));

            case ClrToV8ConversionKind.FromInt32:
                return(CefV8Value.CreateInt((int)value));

            case ClrToV8ConversionKind.FromUInt32:
                return(CefV8Value.CreateUInt((uint)value));

            case ClrToV8ConversionKind.FromBool:
                return(CefV8Value.CreateBool((bool)value));
            }
            return(new CefV8Value());
        }
Example #2
0
        static ClrToV8ConversionKind GetConvKind(Type t)
        {
            ClrToV8ConversionKind convKind = ClrToV8ConversionKind.Unknown;

            if (t == typeof(string))
            {
                convKind = ClrToV8ConversionKind.FromString;
            }
            else if (t == typeof(double))
            {
                //convert to number
                convKind = ClrToV8ConversionKind.FromDouble;
            }
            else if (t == typeof(int))
            {
                convKind = ClrToV8ConversionKind.FromInt32;
            }
            else if (t == typeof(uint))
            {
                convKind = ClrToV8ConversionKind.FromUInt32;
            }
            else if (t == typeof(bool))
            {
                convKind = ClrToV8ConversionKind.FromBool;
            }
            else if (t == typeof(object))
            {
                convKind = ClrToV8ConversionKind.FromObject;
            }
            else
            {
                //other type
                convKind = ClrToV8ConversionKind.Unknown;
            }
            return(convKind);
        }
Example #3
0
 static JsValueArgTypeEvaluator()
 {
     conversionKind = GetConvKind(typeof(T));
 }