Example #1
0
        /// <summary>
        /// Returns instance.GetCustomType() if the instance implements ICustomTypeProvider; otherwise,
        /// returns instance.GetType().
        /// </summary>
        /// <param name="instance">Object to return the type of</param>
        /// <returns>Type of the instance</returns>
        internal static Type GetCustomOrCLRType(this object instance)
        {
            ICustomTypeProvider customTypeProvider = instance as ICustomTypeProvider;

            if (customTypeProvider != null)
            {
                return(customTypeProvider.GetCustomType() ?? instance.GetType());
            }

            return(instance == null ? null : instance.GetType());
        }
        /// <summary>
        /// Returns instance.GetCustomType() if the instance implements ICustomTypeProvider; otherwise,
        /// returns instance.GetType().
        /// </summary>
        /// <param name="instance">Object to return the type of</param>
        /// <returns>Type of the instance</returns>
        internal static Type GetCustomOrCLRType(this object instance)
        {
#if !WINDOWS_UWP && !HAS_UNO
            ICustomTypeProvider customTypeProvider = instance as ICustomTypeProvider;
            if (customTypeProvider != null)
            {
                return(customTypeProvider.GetCustomType() ?? instance.GetType());
            }
#endif

            return(instance == null ? null : instance.GetType());
        }
        private static Type GetCustomOrCLRType(object instance)
        {
            ICustomTypeProvider icustomTypeProvider = instance as ICustomTypeProvider;

            if (icustomTypeProvider != null)
            {
                return(icustomTypeProvider.GetCustomType() ?? instance.GetType());
            }
            else
            {
                return(instance.GetType());
            }
        }
Example #4
0
        internal static Type GetReflectionType(object item)
        {
            if (item == null)
            {
                return(null);
            }
            ICustomTypeProvider customTypeProvider = item as ICustomTypeProvider;

            if (customTypeProvider == null)
            {
                return(item.GetType());
            }
            return(customTypeProvider.GetCustomType());
        }
Example #5
0
        /// <summary>
        /// Get the type to use for reflection:  the custom type, if any, otherwise just the type.
        /// </summary>
        internal static Type GetReflectionType(object item)
        {
            if (item == null)
            {
                return(null);
            }

            ICustomTypeProvider ictp = item as ICustomTypeProvider;

            if (ictp == null)
            {
                return(item.GetType());
            }
            else
            {
                return(ictp.GetCustomType());
            }
        }
Example #6
0
 public CustomTypeProviderAdapter(ICustomTypeProvider typeProvider) => this.typeProvider = typeProvider;