Esempio n. 1
0
        /// <summary>
        /// Analyze the given type looking for dependencies on other type libraries
        /// </summary>
        /// <param name="typeInfo"></param>
        private void AnalyzeTypeInfo(ITypeInfo typeInfo)
        {
            ITypeLib containingTypeLib = null;
            int      indexInContainingTypeLib;

            try
            {
                typeInfo.GetContainingTypeLib(out containingTypeLib, out indexInContainingTypeLib);

                TYPELIBATTR containingTypeLibAttributes;
                ComReference.GetTypeLibAttrForTypeLib(ref containingTypeLib, out containingTypeLibAttributes);

                // Have we analyzed this type info already? If so skip it.
                AnalyzedTypesInfoKey typeInfoId = new AnalyzedTypesInfoKey(
                    containingTypeLibAttributes.guid, containingTypeLibAttributes.wMajorVerNum,
                    containingTypeLibAttributes.wMinorVerNum, containingTypeLibAttributes.lcid, indexInContainingTypeLib);

                // Get enough information about the type to figure out if we want to register it as a dependency
                TYPEATTR typeAttributes;

                ComReference.GetTypeAttrForTypeInfo(typeInfo, out typeAttributes);

                // Is it one of the types we don't care about?
                if (!CanSkipType(typeInfo, containingTypeLib, typeAttributes, containingTypeLibAttributes))
                {
                    _dependencies.Add(containingTypeLibAttributes);

                    if (_analyzedTypes.Add(typeInfoId))
                    {
                        // We haven't already analyzed this type, so rescan
                        ScanImplementedTypes(typeInfo, typeAttributes);
                        ScanDefinedVariables(typeInfo, typeAttributes);
                        ScanDefinedFunctions(typeInfo, typeAttributes);
                    }
                }
                // Make sure if we encounter this type again, we won't rescan it, since we already know we can skip it
                else
                {
                    _analyzedTypes.Add(typeInfoId);
                }
            }
            finally
            {
                if (containingTypeLib != null)
                {
                    _marshalReleaseComObject(containingTypeLib);
                }
            }
        }
Esempio n. 2
0
        private void AnalyzeTypeInfo(ITypeInfo typeInfo)
        {
            ITypeLib ppTLB = null;

            try
            {
                int num;
                System.Runtime.InteropServices.ComTypes.TYPELIBATTR typelibattr;
                System.Runtime.InteropServices.ComTypes.TYPEATTR    typeattr;
                typeInfo.GetContainingTypeLib(out ppTLB, out num);
                ComReference.GetTypeLibAttrForTypeLib(ref ppTLB, out typelibattr);
                string key = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}:{4}", new object[] { typelibattr.guid, typelibattr.wMajorVerNum, typelibattr.wMinorVerNum, typelibattr.lcid, num });
                ComReference.GetTypeAttrForTypeInfo(typeInfo, out typeattr);
                if (!this.CanSkipType(typeInfo, ppTLB, typeattr, typelibattr))
                {
                    this.dependencies[typelibattr] = null;
                    if (!this.analyzedTypes.ContainsKey(key))
                    {
                        this.analyzedTypes.Add(key, null);
                        this.ScanImplementedTypes(typeInfo, typeattr);
                        this.ScanDefinedVariables(typeInfo, typeattr);
                        this.ScanDefinedFunctions(typeInfo, typeattr);
                    }
                }
                else if (!this.analyzedTypes.ContainsKey(key))
                {
                    this.analyzedTypes.Add(key, null);
                }
            }
            finally
            {
                if (ppTLB != null)
                {
                    this.marshalReleaseComObject(ppTLB);
                }
            }
        }