/// <summary>
        ///    Creates a new DbgValueConverterInfo object.
        /// </summary>
        /// <param name="typeName">
        ///    This can be module-qualified (like "dfsrs!_FILETIME"), or not (like
        ///    "!_FILETIME").
        /// </param>
        public DbgValueConverterInfo(string typeName, IDbgValueConverter converter, string sourceScript)
        {
            if (String.IsNullOrEmpty(typeName))
            {
                throw new ArgumentException("You must supply a type name.", "typeName");
            }

            if (null == converter)
            {
                throw new ArgumentNullException("converter");
            }

            int bangIdx = typeName.IndexOf('!');

            if (bangIdx < 0)
            {
                m_typeName = DbgTemplateNode.CrackTemplate(typeName);
            }
            else
            {
                ScopingModule = typeName.Substring(0, bangIdx);
                if (bangIdx == (typeName.Length - 1))
                {
                    throw new ArgumentException("No type name after the '!'.", typeName);
                }

                var tn = typeName.Substring(bangIdx + 1);
                m_typeName = DbgTemplateNode.CrackTemplate(tn);
            }

            Converter    = converter;
            SourceScript = sourceScript;
        } // end constructor
        } // end FindMatchingItems()

        /// <summary>
        ///    Enumerates all items that have the exact same template.
        /// </summary>
        /// <remarks>
        ///    Items with templates that match but are not exact matches will not be
        ///    returned.
        /// </remarks>
        public IEnumerable <TItem> FindMatchingItemsExact(string typeName)
        {
            if (String.IsNullOrEmpty(typeName))
            {
                throw new ArgumentException("You must supply a type name.", "typeName");
            }

            DbgTemplateNode matchMe = DbgTemplateNode.CrackTemplate(typeName);

            return(FindMatchingItemsExact(matchMe));
        } // end FindMatchingItemsExact()
        } // end class ExactMatchEqualityComparer


        /// <summary>
        ///    Attempts to find an item with a matching template.
        /// </summary>
        /// <remarks>
        ///    There may be multiple matches in the list; this just returns the first
        ///    match, where matches are made according to priority order.
        /// </remarks>
        public TItem TryFindMatchingItem(string typeName)
        {
            if (String.IsNullOrEmpty(typeName))
            {
                throw new ArgumentException("You must supply a type name.", "typeName");
            }

            DbgTemplateNode matchMe = DbgTemplateNode.CrackTemplate(typeName);

            return(TryFindMatchingItem(matchMe));
        } // end TryFindMatchingItem()
示例#4
0
        } // end _AddBaseClassNodesToList()

        private void _AddBaseClassPointerNodesToList(List <DbgTemplateNode> list, DbgPointerTypeInfo pti)
        {
            DbgNamedTypeInfo dnti = pti;
            int numStars          = 0;

            while (dnti is DbgPointerTypeInfo)
            {
                dnti = ((DbgPointerTypeInfo)dnti).PointeeType;
                numStars++;
            }

            if (!typeof(DbgUdtTypeInfo).IsAssignableFrom(dnti.GetType()))
            {
                return; // It doesn't point to a UDT.
            }
            string stars = new String('*', numStars);
            var    q     = new Queue <DbgUdtTypeInfo>();
            var    uti   = (DbgUdtTypeInfo)dnti;

            uti.VisitAllBaseClasses((bc) => list.Add(DbgTemplateNode.CrackTemplate(bc.TemplateNode.FullName + stars)));
        } // end _AddBaseClassPointerNodesToList()
示例#5
0
        public IReadOnlyList <DbgTemplateNode> GetTemplateNodes()
        {
            if (null == m_templateNodes)
            {
                var templateTypeNames = new List <DbgTemplateNode>();
                DbgArrayTypeInfo ati  = this as DbgArrayTypeInfo;
                if (null != ati)
                {
                    templateTypeNames.Add(DbgTemplateNode.CrackTemplate(ati.ArrayElementType.Name + "[]"));     // we don't want the dimensions
                    // TODO: And maybe for array types, we'd like to include the array type /with/ dimensions,
                    // so that, for instance, all Foo[8] could be treated specially or something. But maybe that's
                    // stretching it.

                    // TODO: How about co-(or is it contra-)variance? (should we get base types of the element type, like we do for pointers?)
                }
                else if (typeof(DbgUdtTypeInfo).IsAssignableFrom(GetType()))
                {
                    DbgUdtTypeInfo uti = (DbgUdtTypeInfo)this;
                    templateTypeNames.Add(uti.TemplateNode);
                    _AddBaseClassNodesToList(templateTypeNames, uti);
                }
                else if (typeof(DbgPointerTypeInfo).IsAssignableFrom(GetType()))
                {
                    DbgPointerTypeInfo pti = (DbgPointerTypeInfo)this;
                    templateTypeNames.Add(pti.TemplateNode);
                    _AddBaseClassPointerNodesToList(templateTypeNames, pti);
                }
                else
                {
                    templateTypeNames.Add(DbgTemplateNode.CrackTemplate(Name));
                }

                m_templateNodes = templateTypeNames.AsReadOnly();
            }
            return(m_templateNodes);
        } // end GetTemplateNodes()