コード例 #1
0
        /// <summary>
        /// Tries to get the <see cref="EtpSupportedDataObject"/> matching the specified <see cref="IDataObjectType"/>.
        /// </summary>
        /// <param name="dataObjectType">The type to try to get the matching <see cref="EtpSupportedDataObject"/> for.</param>
        /// <returns>
        /// If there is a specific type matching the specified data object type, it is returned.
        /// Otherwise, if there is a family that matches the specified data object type, it is returned.
        /// Otherwise, <c>null</c> is returned.
        /// </returns>
        public EtpSupportedDataObject TryGetMatchingDataObject(IDataObjectType dataObjectType)
        {
            if (dataObjectType == null || !dataObjectType.IsValid || dataObjectType.IsBaseType)
            {
                return(null);
            }

            EtpSupportedDataObject sessionDataObject;

            if (!dataObjectType.IsWildcard)
            {
                if (SupportedDataObjectsByType.TryGetValue(dataObjectType.Key, out sessionDataObject))
                {
                    return(sessionDataObject);
                }

                dataObjectType = dataObjectType.ToWildCard();
            }

            if (SupportedDataObjectsByFamily.TryGetValue(dataObjectType.Key, out sessionDataObject))
            {
                return(sessionDataObject);
            }

            return(null);
        }