Ejemplo n.º 1
0
        public override void VisitAssemblyNameReference(AssemblyNameReference name)
        {
            byte [] pkortoken;
            if (name.PublicKey != null && name.PublicKey.Length > 0)
            {
                pkortoken = name.PublicKey;
            }
            else if (name.PublicKeyToken != null && name.PublicKeyToken.Length > 0)
            {
                pkortoken = name.PublicKeyToken;
            }
            else
            {
                pkortoken = new byte [0];
            }

            AssemblyRefTable arTable = m_tableWriter.GetAssemblyRefTable();
            AssemblyRefRow   arRow   = m_rowWriter.CreateAssemblyRefRow(
                (ushort)name.Version.Major,
                (ushort)name.Version.Minor,
                (ushort)name.Version.Build,
                (ushort)name.Version.Revision,
                name.Flags,
                m_mdWriter.AddBlob(pkortoken),
                m_mdWriter.AddString(name.Name),
                m_mdWriter.AddString(name.Culture),
                m_mdWriter.AddBlob(name.Hash));

            arTable.Rows.Add(arRow);
        }
Ejemplo n.º 2
0
        public override void VisitAssemblyNameReferenceCollection(AssemblyNameReferenceCollection names)
        {
            if (!m_tHeap.HasTable(AssemblyRefTable.RId))
            {
                return;
            }

            AssemblyRefTable arTable = m_tableReader.GetAssemblyRefTable();

            for (int i = 0; i < arTable.Rows.Count; i++)
            {
                AssemblyRefRow        arRow = arTable [i];
                AssemblyNameReference aname = new AssemblyNameReference(
                    ReadString(arRow.Name),
                    ReadString(arRow.Culture),
                    new Version(arRow.MajorVersion, arRow.MinorVersion,
                                arRow.BuildNumber, arRow.RevisionNumber));
                aname.PublicKeyToken = ReadBlob(arRow.PublicKeyOrToken);
                aname.Hash           = ReadBlob(arRow.HashValue);
                aname.MetadataToken  = new MetadataToken(TokenType.AssemblyRef, (uint)i + 1);
                names.Add(aname);
            }
        }