Пример #1
0
        /// <summary>
        /// Determines whether the specified type is an <see cref="ExtensibleEnum{T}"/> type.
        /// </summary>
        /// <param name="type">The type to be checked.</param>
        /// <returns>
        ///   <see langword="true"/> if the specified type is an extensible enum type; otherwise, <see langword="false"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">The <paramref name="type"/> parameter is <see langword="null" />.</exception>
        /// <remarks>
        /// For performance reasons, this method only checks if the <paramref name="type"/> implements <see cref="IExtensibleEnum"/>, it does not
        /// check whether the type is derived from <see cref="ExtensibleEnum{T}"/>. The <see cref="GetDefinition"/> method, however, will throw
        /// an exception when used with a type not derived from <see cref="ExtensibleEnum{T}"/>.
        /// </remarks>
        public static bool IsExtensibleEnumType(ITypeInformation type)
        {
            ArgumentUtility.CheckNotNull("type", type);

            return(s_extensibleEnumInterfaceType.IsAssignableFrom(type) &&
                   !type.Equals(s_extensibleEnumGenericBaseType) &&
                   !(type.IsGenericType && type.GetGenericTypeDefinition().Equals(s_extensibleEnumGenericBaseType)) &&
                   !type.Equals(s_extensibleEnumInterfaceType));
        }
Пример #2
0
        private string GetTypeNameInternal(ITypeInformation typeInformation)
        {
            if (typeInformation.IsGenericType && !typeInformation.IsGenericTypeDefinition)
            {
                typeInformation = typeInformation.GetGenericTypeDefinition();
            }

            return(typeInformation.FullName);
        }