private void GetTypeReferences() { IntPtr enumHandle = IntPtr.Zero; uint[] typeRefs = new uint[NuGenProject.DefaultArrayCount]; uint count = 0; Import.EnumTypeRefs(ref enumHandle, typeRefs, Convert.ToUInt32(typeRefs.Length), out count); if (count > 0) { TypeReferences = new List<NuGenTypeReference>(); } while (count > 0) { for (uint typeRefsIndex = 0; typeRefsIndex < count; typeRefsIndex++) { uint token = typeRefs[typeRefsIndex]; uint typeRefNameLength; uint resolutionScope; Import.GetTypeRefProps(token, out resolutionScope, NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeRefNameLength); if (typeRefNameLength > NuGenProject.DefaultCharArray.Length) { NuGenProject.DefaultCharArray = new char[typeRefNameLength]; Import.GetTypeRefProps(token, out resolutionScope, NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out typeRefNameLength); } NuGenTypeReference typeReference = new NuGenTypeReference(Import, this, NuGenHelperFunctions.GetString(NuGenProject.DefaultCharArray, 0, typeRefNameLength), token, resolutionScope); TypeReferences.Add(typeReference); AllTokens[token] = typeReference; } Import.EnumTypeRefs(ref enumHandle, typeRefs, Convert.ToUInt32(typeRefs.Length), out count); } Import.CloseEnum(enumHandle); }
private void FindReferencedAssembly(NuGenTypeReference typeReference, uint resolutionScope, bool recursiveCall) { NuGenTokenBase tokenObject = AllTokens[resolutionScope]; if (tokenObject is NuGenTypeReference) { NuGenTypeReference typeReferenceToken = (NuGenTypeReference)tokenObject; FindReferencedAssembly(typeReference, typeReferenceToken.ResolutionScope, true); typeReference.FullName = string.Format("{0}/{1}", typeReferenceToken.FullName, typeReference.Name); } else if (tokenObject is NuGenModuleScope) { typeReference.FullName = typeReference.Name; } else { typeReference.ReferencedAssembly = tokenObject.Name; if (recursiveCall) { typeReference.FullName = string.Format("[{0}]{1}", typeReference.ReferencedAssembly, tokenObject.Name); } else { typeReference.FullName = string.Format("[{0}]{1}", typeReference.ReferencedAssembly, typeReference.Name); } } }