Exemple #1
0
        public static JniType GetCachedJniType(ref JniType cachedType, string classname)
        {
            if (cachedType != null && cachedType.PeerReference.IsValid)
            {
                return(cachedType);
            }
            var t = new JniType(classname);

            if (Interlocked.CompareExchange(ref cachedType, t, null) != null)
            {
                t.Dispose();
            }
            cachedType.RegisterWithRuntime();
            return(cachedType);
        }
            internal void Dispose()
            {
                if (InstanceMethods == null)
                {
                    return;
                }

                // Don't dispose JniPeerType; it's shared with others.
                InstanceMethods = null;

                foreach (var p in SubclassConstructors.Values)
                {
                    p.Dispose();
                }
                SubclassConstructors = null;

                if (jniPeerType != null)
                {
                    jniPeerType.Dispose();
                }
                jniPeerType = null;
            }
Exemple #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing || jniPeerType == null)
            {
                return;
            }

            instanceMethods.Dispose();
            instanceMethods = null;

            instanceFields.Dispose();
            instanceFields = null;

            staticMethods.Dispose();
            staticMethods = null;

            staticFields.Dispose();
            staticFields = null;

            jniPeerType.Dispose();
            jniPeerType = null;
        }