Example #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                var java = Value as IJavaPeerable;
                if (java != null)
                {
                    java.DisposeUnlessReferenced();
                }

                if (klass != null)
                {
                    klass.Dispose();
                }
            }

            disposed = true;
            Value    = null;
            klass    = null;
        }
Example #2
0
        public DynamicJavaClass(string jniClassName)
        {
            if (jniClassName == null)
            {
                throw new ArgumentNullException("jniClassName");
            }

            JniClassName = jniClassName;
            info         = JavaClassInfo.GetClassInfo(jniClassName);
        }
Example #3
0
        public DynamicJavaInstance(IJavaPeerable value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            Value = value;

            var type = JniEnvironment.Types.GetJniTypeNameFromInstance(value.PeerReference);

            klass = JavaClassInfo.GetClassInfo(type);
        }
Example #4
0
        public static JavaClassInfo   GetClassInfo(string jniClassName)
        {
            lock (Classes) {
                JavaClassInfo info = _GetClassInfo(jniClassName);
                if (info != null)
                {
                    Interlocked.Increment(ref info.RefCount);
                    return(info);
                }

                info = new JavaClassInfo(jniClassName);
                Classes.Add(jniClassName, new WeakReference(info));
                return(info);
            }
        }
Example #5
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            if (disposed)
            {
                return;
            }

            info.Dispose();
            info     = null;
            disposed = true;
        }
Example #6
0
        public void LookupArguments()
        {
            if (arguments != null)
            {
                return;
            }

            var vm  = JniEnvironment.Runtime;
            var sb  = new StringBuilder();
            var mgr = vm.TypeManager;

            if (!IsConstructor)
            {
                sb.Append(Name).Append(".");
            }

            sb.Append("(");

            var parameters = IsConstructor
                                ? JavaClassInfo.GetConstructorParameters(PeerReference)
                                : JavaClassInfo.GetMethodParameters(PeerReference);

            try {
                int len = JniEnvironment.Arrays.GetArrayLength(parameters);
                arguments = new List <JniObjectReference> (len);
                for (int i = 0; i < len; ++i)
                {
                    var p = JniEnvironment.Arrays.GetObjectArrayElement(parameters, i);
                    try {
                        var sig = JniTypeSignature.Parse(JniEnvironment.Types.GetJniTypeNameFromClass(p));
                        sb.Append(sig.QualifiedReference);
                        arguments.Add(p.NewGlobalRef());
                    } finally {
                        JniObjectReference.Dispose(ref p);
                    }
                }
            } finally {
                JniObjectReference.Dispose(ref parameters);
            }
            sb.Append(")").Append(JniReturnType);
            JniSignature = sb.ToString();
        }
Example #7
0
 public JniMetaObject(Expression parameter, object value, JavaClassInfo info)
     : base(parameter, BindingRestrictions.GetInstanceRestriction(parameter, value), value)
 {
     this.info = info;
 }