Example #1
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;
        }
Example #2
0
        JniPeerMembers(string jniPeerTypeName, Type managedPeerType, bool checkManagedPeerType, bool isInterface = false)
        {
            if (jniPeerTypeName == null)
            {
                throw new ArgumentNullException(nameof(jniPeerTypeName));
            }

            if (checkManagedPeerType)
            {
                if (managedPeerType == null)
                {
                    throw new ArgumentNullException(nameof(managedPeerType));
                }
                if (!typeof(IJavaPeerable).IsAssignableFrom(managedPeerType))
                {
                    throw new ArgumentException("'managedPeerType' must implement the IJavaPeerable interface.", nameof(managedPeerType));
                }

#if !XA_INTEGRATION
                Debug.Assert(
                    JniEnvironment.Runtime.TypeManager.GetTypeSignature(managedPeerType).SimpleReference == jniPeerTypeName,
                    string.Format("ManagedPeerType <=> JniTypeName Mismatch! javaVM.GetJniTypeInfoForType(typeof({0})).JniTypeName=\"{1}\" != \"{2}\"",
                                  managedPeerType.FullName,
                                  JniEnvironment.Runtime.TypeManager.GetTypeSignature(managedPeerType).SimpleReference,
                                  jniPeerTypeName));
#endif  // !XA_INTEGRATION
            }

            JniPeerTypeName = jniPeerTypeName;
            ManagedPeerType = managedPeerType;

            this.isInterface = isInterface;

            instanceMethods = new JniInstanceMethods(this);
            instanceFields  = new JniInstanceFields(this);
            staticMethods   = new JniStaticMethods(this);
            staticFields    = new JniStaticFields(this);
        }