public virtual object Wrap(Context cx, Scriptable scope, object obj, Type staticType)
{
if (obj == null || obj == Undefined.instance || obj is Scriptable)
{
return obj;
}
if (staticType != null && staticType.IsPrimitive)
{
if (staticType == typeof(void))
{
return Undefined.instance;
}
if (staticType == typeof(char))
{
return Sharpen.Extensions.ValueOf(((char)obj));
}
return obj;
}
if (!IsJavaPrimitiveWrap())
{
if (obj is string || obj is Number || obj is bool)
{
return obj;
}
else
{
if (obj is char)
{
return ((char)obj).ToString();
}
}
}
Type cls = obj.GetType();
if (cls.IsArray)
{
return NativeJavaArray.Wrap(scope, obj);
}
return WrapAsJavaObject(cx, scope, obj, staticType);
}