/// <summary>Try and get the API resource type by CLR type object.</summary>
        /// <typeparam name="TResource">CLR resource type object to lookup the API resource type by.</typeparam>
        /// <param name="apiResourceType">The API resource type if it exists in the API schema, null otherwise.</param>
        /// <returns>True if API resource type exists in the API schema, false otherwise.</returns>
        /// <remarks>If the CLR type exists but is an API complex object, then this method returns false.</remarks>
        public static bool TryGetApiResourceType <TResource>(this IApiSchema apiSchema, out IApiObjectType apiResourceType)
        {
            Contract.Requires(apiSchema != null);

            var clrResourceType = typeof(TResource);

            return(apiSchema.TryGetApiResourceType(clrResourceType, out apiResourceType));
        }
        /// <summary>Get the API resource type by CLR resource type object.</summary>
        /// <param name="clrResourceType">CLR resource type object to lookup the API resource type by.</param>
        /// <returns>The API resource type in the API schema, otherwise an exception is thrown.</returns>
        /// <exception cref="ApiSchemaException"></exception>
        public static IApiObjectType GetApiResourceType(this IApiSchema apiSchema, Type clrResourceType)
        {
            Contract.Requires(apiSchema != null);
            Contract.Requires(clrResourceType != null);

            if (apiSchema.TryGetApiResourceType(clrResourceType, out var apiResourceType))
            {
                return(apiResourceType);
            }

            // Unable to get API resource type by the given CLR resource type.
            var message = $"Unable to get API resource type [clrResourceType={clrResourceType.Name}] in the API schema, API resource type was not configured or is not an API resource type.";

            throw new ApiSchemaException(message);
        }
        /// <summary>Get the API resource type by API type name.</summary>
        /// <param name="apiName">API type name to lookup the API resource type by.</param>
        /// <returns>The API resource type in the API schema, otherwise an exception is thrown.</returns>
        /// <exception cref="ApiSchemaException"></exception>
        public static IApiObjectType GetApiResourceType(this IApiSchema apiSchema, string apiName)
        {
            Contract.Requires(apiSchema != null);
            Contract.Requires(apiName.SafeHasContent());

            if (apiSchema.TryGetApiResourceType(apiName, out var apiResourceType))
            {
                return(apiResourceType);
            }

            // Unable to get API resource type by the given API name.
            var message = $"Unable to get API resource type [apiName={apiName}] in the API schema, API resource type was not configured or is not an API resource type.";

            throw new ApiSchemaException(message);
        }