/// <summary>
        /// Tries to get an instance of a custom property field provided by an implementation of <see cref="ICustomPropertyField{T}"/>.
        /// </summary>
        /// <param name="propertyType">The type for which to get the custom property field.</param>
        /// <param name="customPropertyField">On exit, the custom property field instance.</param>
        /// <returns>True if a custom property field was found, false otherwise.</returns>
        protected static bool TryGetCustomPropertyField(Type propertyType, out ICustomPropertyField customPropertyField)
        {
            if (s_CustomPropertyFields == null)
            {
                s_CustomPropertyFields = new Dictionary <Type, Type>();

                var customPropertyDrawerTypes = TypeCache.GetTypesDerivedFrom <ICustomPropertyField>();
                foreach (var customPropertyDrawerType in customPropertyDrawerTypes)
                {
                    // We only want non-generic non-abstract types that derive from a generic type.
                    if (customPropertyDrawerType.IsGenericType ||
                        customPropertyDrawerType.IsAbstract ||
                        customPropertyDrawerType.BaseType == null ||
                        customPropertyDrawerType.BaseType.GenericTypeArguments.Length == 0)
                    {
                        continue;
                    }

                    var typeParam = customPropertyDrawerType.BaseType.GenericTypeArguments[0];
                    s_CustomPropertyFields.Add(typeParam, customPropertyDrawerType);
                }
            }

            if (s_CustomPropertyFields.TryGetValue(propertyType, out var propertyDrawerType))
            {
                customPropertyField = Activator.CreateInstance(propertyDrawerType) as ICustomPropertyField;
                return(true);
            }

            customPropertyField = null;
            return(false);
        }
        /// <summary>
        /// Tries to get an instance of a custom property field provided by an implementation of <see cref="ICustomPropertyField{T}"/>.
        /// </summary>
        /// <param name="customPropertyField">On exit, the custom property field instance.</param>
        /// <typeparam name="T">The type for which to get the custom property field.</typeparam>
        /// <returns>True if a custom property field was found, false otherwise.</returns>
        protected static bool TryGetCustomPropertyField <T>(out ICustomPropertyField <T> customPropertyField)
        {
            if (TryGetCustomPropertyField(typeof(T), out var customPropertyDrawerNonTyped))
            {
                customPropertyField = customPropertyDrawerNonTyped as ICustomPropertyField <T>;
                return(true);
            }

            customPropertyField = null;
            return(false);
        }