public static Java.Lang.Object ToNative(Type type, object data)
        {
            var dataType = data.GetType();

            if (dataType.IsPrimitive || data is string)
            {
                if (data is bool b)
                {
                    return(new Java.Lang.Boolean(b));
                }
                else if (data is float f)
                {
                    return(new Java.Lang.Float(f));
                }
                else if (data is double d)
                {
                    return(new Java.Lang.Double(d));
                }
                else if (data is long l)
                {
                    return(new Java.Lang.Long(l));
                }
                else if (data is int i)
                {
                    return(new Java.Lang.Integer(i));
                }
                else if (data is string s)
                {
                    return(new Java.Lang.String(s));
                }
                return((Java.Lang.Object)data);
            }
            else if (data is IDictionary dict)
            {
                var ret       = new JavaDictionary <string, Java.Lang.Object>();
                var valueType = DataConverter.GetItemType(dict.GetType(), 1);
                foreach (var key in dict.Keys)
                {
                    ret.Add(key as string, ToNative(valueType, dict[key]));
                }
                return(ret);
            }
            else
            {
                var ret = new JavaDictionary <string, Java.Lang.Object>();
                foreach (var item in TypePropertyHelper.GetFirebaseProperties(type))
                {
                    var prp     = item.Value.Property;
                    var key     = item.Key;
                    var objData = prp.GetValue(data);
                    if (objData != null)
                    {
                        ret.Add(key, ToNative(prp.PropertyType, objData));
                    }
                }
                return(ret);
            }
            //return (Java.Lang.Object) data;
        }
        internal static IDictionary <string, Java.Lang.Object> ToDictionary <T>(Type type, T data)
        {
            if (data is IDictionary dict)
            {
                var ret       = new Dictionary <string, Java.Lang.Object>();
                var valueType = DataConverter.GetItemType(dict.GetType(), 1);
                foreach (var key in dict.Keys)
                {
                    ret.Add(key as string, ToNative(valueType, dict[key]));
                }
                return(ret);
            }
            else
            {
                var ret = new Dictionary <string, Java.Lang.Object>();
                foreach (var item in TypePropertyHelper.GetFirebaseProperties(type))
                {
                    if (!item.Value.CustomAttribute.ReadOnly)
                    {
                        var prp     = item.Value.Property;
                        var key     = item.Key;
                        var objData = prp.GetValue(data);
                        if (objData != null)
                        {
                            ret.Add(key, ToNative(prp.PropertyType, objData));
                        }
                        else
                        {
                            ret.Add(key, null);
                        }
                    }
                }
                return(ret);
            }

            throw new UnknownFormatConversionException("Convert failed, not possible to convert to dictionary");
        }