コード例 #1
0
        private ComTypeLibrary GetComTypeLibrary(ITypeLib typeLib)
        {
            Guid    typeLibGuid    = typeLib.GetGuid();
            Version typeLibVersion = typeLib.GetVersion();

            ComTypeLibrary comTypeLibrary = _typeLibraries.Where(
                x => x.Guid.Equals(typeLibGuid)).Where(
                x => x.Version.Equals(typeLibVersion)
                ).FirstOrDefault();

            if (comTypeLibrary == null)
            {
                comTypeLibrary = new ComTypeLibrary(typeLib);
                _typeLibraries.Add(comTypeLibrary);
                _typeLibraries.Sort(delegate(ComTypeLibrary a, ComTypeLibrary b)
                {
                    return(a.Name.CompareTo(b.Name));
                });
            }

            return(comTypeLibrary);
        }
コード例 #2
0
        private static IEnumerable <ITypeInfo> GetReferencedEnums(ITypeLib typeLib, ITypeInfo typeInfo, Dictionary <Guid, ITypeInfo> processedTypeInfo)
        {
            if (typeInfo == null)
            {
                yield break;
            }

            var guid = typeInfo.GetOrCreateGuid();

            if (processedTypeInfo.ContainsKey(guid))
            {
                yield break;
            }

            processedTypeInfo.Add(guid, typeInfo);

            if (typeInfo.IsEnum())
            {
                yield return(typeInfo);

                yield break;
            }

            if (typeInfo.GetContainingTypeLib().GetGuid() != typeLib.GetGuid())
            {
                yield break;
            }

            using (var typeAttrScope = typeInfo.CreateAttrScope())
            {
                for (var funcIndex = 0; funcIndex < typeAttrScope.Value.cFuncs; funcIndex++)
                {
                    using (var funcDescScope = typeInfo.CreateFuncDescScope(funcIndex))
                    {
                        foreach (var enumTypeInfo in GetReferencedEnums(typeLib, typeInfo, funcDescScope.Value, processedTypeInfo))
                        {
                            yield return(enumTypeInfo);
                        }
                    }
                }

                for (var varIndex = 0; varIndex < typeAttrScope.Value.cVars; varIndex++)
                {
                    using (var varDescScope = typeInfo.CreateVarDescScope(varIndex))
                    {
                        foreach (var enumTypeInfo in GetReferencedEnums(typeLib, typeInfo, varDescScope.Value, processedTypeInfo))
                        {
                            yield return(enumTypeInfo);
                        }
                    }
                }

                for (var implTypeIndex = 0; implTypeIndex < typeAttrScope.Value.cImplTypes; implTypeIndex++)
                {
                    typeInfo.GetRefTypeOfImplType(implTypeIndex, out var href);
                    typeInfo.GetRefTypeInfo(href, out var refTypeInfo);

                    var refGuid = refTypeInfo.GetGuid();
                    if ((refGuid == typeof(IDispatch).GUID) || (refGuid == typeof(IDispatchEx).GUID))
                    {
                        continue;
                    }

                    foreach (var enumTypeInfo in GetReferencedEnums(typeLib, refTypeInfo, processedTypeInfo))
                    {
                        yield return(enumTypeInfo);
                    }
                }
            }
        }
コード例 #3
0
        private ComTypeLibrary GetComTypeLibrary(ITypeLib typeLib)
        {
            Guid typeLibGuid = typeLib.GetGuid();
            Version typeLibVersion = typeLib.GetVersion();

            ComTypeLibrary comTypeLibrary = _typeLibraries.Where(
                x => x.Guid.Equals(typeLibGuid)).Where(
                x => x.Version.Equals(typeLibVersion)
                ).FirstOrDefault();

            if (comTypeLibrary == null)
            {
                comTypeLibrary = new ComTypeLibrary(typeLib);
                _typeLibraries.Add(comTypeLibrary);
                _typeLibraries.Sort(delegate(ComTypeLibrary a, ComTypeLibrary b)
                {
                    return a.Name.CompareTo(b.Name);
                });
            }

            return comTypeLibrary;
        }