Пример #1
0
        /// <summary>
        /// Returns the interface reference when it matches <typeparamref name="T_Intf"/>.
        /// </summary>
        /// <typeparam name="T_Intf">The type of interface to match.</typeparam>
        /// <returns>Returns null when no match could be made.</returns>
        public ExtensibleInterfaceRef <T> MatchInterface <T_Intf>() where T_Intf : class
        {
            if (ExtensibleInterfaceRef <T> .IsMatch <T_Intf>())
            {
                return(GetInterface());
            }

            return(null);
        }
Пример #2
0
        /// <summary>
        /// Disposes the interface reference.
        /// </summary>
        public void Dispose()
        {
            if (_interfaceRef != null)
            {
                _interfaceRef.Dispose();
                _interfaceRef = null;
            }

            _createCallback = null;
        }
Пример #3
0
        /// <summary>
        /// Returns the interface reference.
        /// </summary>
        /// <returns>Never returns null.</returns>
        public ExtensibleInterfaceRef <T> GetInterface()
        {
            if (_interfaceRef == null)
            {
                _interfaceRef = new ExtensibleInterfaceRef <T>();

                _interfaceRef.Instance        = _createCallback(null);
                _interfaceRef.DisposeInstance = (DisposeParent != _interfaceRef.Instance);
            }
            else if (!_interfaceRef.IsConstructionThread && _interfaceRef.ThreadSafeInstance == null)
            {
                _interfaceRef.ThreadSafeInstance        = _createCallback(_interfaceRef.Instance);
                _interfaceRef.DisposeThreadSafeInstance = (DisposeParent != _interfaceRef.ThreadSafeInstance);
            }

            return(_interfaceRef);
        }