Exemplo n.º 1
0
        public static JavaProxyObject GetProxy(object value)
        {
            if (value == null)
            {
                return(null);
            }

            lock (CachedValues) {
                JavaProxyObject proxy;
                if (CachedValues.TryGetValue(value, out proxy))
                {
                    return(proxy);
                }
                proxy = new JavaProxyObject(value);
                CachedValues.Add(value, proxy);
                return(proxy);
            }
        }
Exemplo n.º 2
0
        public override JniValueMarshalerState CreateGenericObjectReferenceArgumentState(object value, ParameterAttributes synchronize)
        {
            if (value == null)
            {
                return(new JniValueMarshalerState());
            }

            var jvm = JniEnvironment.Runtime;

            var vm = jvm.ValueManager.GetValueMarshaler(value.GetType());

            if (vm != Instance)
            {
                var s = vm.CreateObjectReferenceArgumentState(value, synchronize);
                return(new JniValueMarshalerState(s, vm));
            }

            var p = JavaProxyObject.GetProxy(value);

            return(new JniValueMarshalerState(p.PeerReference.NewLocalRef()));
        }