System.Type.GetInterfaceCount C# (CSharp) Method

GetInterfaceCount() private method

private GetInterfaceCount ( ) : int
return int
        internal int GetInterfaceCount()
        {
            return interfaces.Length;
        }

Usage Example

Ejemplo n.º 1
0
        public bool IsAssignableFrom(Type type)
        {
            // Special hack for handling the merged numeric types
            if (type == typeof (Number))
            {
                if (this == typeof (int) || this == typeof (float) || this == typeof (long) ||
                    this == typeof (byte) || this == typeof (sbyte) || this == typeof (short) ||
                    this == typeof (ushort) || this == typeof (uint) || this == typeof (ulong) ||
                    this == typeof (double))
                {
                    return true;
                }
            }
            // Special hack to allow arbitrary delegates to be force cast into particular delegate
//            if (type == typeof (Delegate) && type.IsAssignableFrom(this))
//            {
//                return true;
//            }


            // Check base type hierarchy
            var current = type;
            while (current != null)
            {
                if (current == this)
                    return true;
                current = current.BaseType;
            }

            // Now check interfaces
            for (var i = 0; i < type.GetInterfaceCount(); i++)
            {
                var item = type.GetInterface(i);
                if (item == this)
                    return true;
            }

            return false;
        }