Exemplo n.º 1
0
        private int getIListCount(Expression targetObject, DebugType iListType)
        {
            PropertyInfo countProperty = iListType.GetGenericInterface("System.Collections.Generic.ICollection").GetProperty("Count");

            try {
                // Do not get string representation since it can be printed in hex later
                Value countValue = targetObject.Evaluate(WindowsDebugger.CurrentProcess).GetPropertyValue(countProperty);
                return((int)countValue.PrimitiveValue);
            } catch (GetValueException) {
                return(-1);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Resolves implementation of a single-generic-argument interface on this type.
        /// </summary>
        /// <param name="fullNamePrefix">Interface name to search for (eg. "System.Collections.Generic.IList")</param>
        /// <param name="implementation">Result found implementation.</param>
        /// <param name="itemType">The only generic argument of <paramref name="implementation"/></param>
        /// <returns>True if found, false otherwise.</returns>
        public static bool ResolveGenericInterfaceImplementation(this DebugType type, string fullNamePrefix, out DebugType implementation, out DebugType itemType)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            implementation = null;
            itemType       = null;

            implementation = type.GetGenericInterface(fullNamePrefix);
            if (implementation != null)
            {
                if (implementation.GetGenericArguments().Length == 1)
                {
                    itemType = (DebugType)implementation.GetGenericArguments()[0];
                    return(true);
                }
            }
            return(false);
        }