public override void VisitMemberReferenceCollection (MemberReferenceCollection members)
		{
			foreach (MemberReference mr in members)
				VisitMemberReference (mr);

			//drop duplicates
			for (int i = 0; i < members.Count; i++) {
				MemberReference mr = members [i];
				for (int j = i + 1; j < members.Count; j++) {
					if (members [j].ToString () == mr.ToString ())
						members.RemoveAt (j);
				}
			}
		}
        internal ModuleDefinition(string name, AssemblyDefinition asm, StructureReader reader, bool main) : base(name)
        {
            if (asm == null)
            {
                throw new ArgumentNullException("asm");
            }
            if (name == null || name.Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            m_asm  = asm;
            m_main = main;
#if !CF_1_0
            m_mvid = Guid.NewGuid();
#endif
            if (reader != null)
            {
                m_image        = reader.Image;
                m_imgReader    = reader.ImageReader;
                m_manifestOnly = reader.ManifestOnly;
            }
            else
            {
                m_image = Image.CreateImage();
            }

            m_modRefs = new ModuleReferenceCollection(this);
            m_asmRefs = new AssemblyNameReferenceCollection(this);
            m_res     = new ResourceCollection(this);
            m_types   = new TypeDefinitionCollection(this);
            m_types.OnTypeDefinitionAdded   += new TypeDefinitionEventHandler(OnTypeDefinitionAdded);
            m_types.OnTypeDefinitionRemoved += new TypeDefinitionEventHandler(OnTypeDefinitionRemoved);
            m_refs = new TypeReferenceCollection(this);
            m_refs.OnTypeReferenceAdded   += new TypeReferenceEventHandler(OnTypeReferenceAdded);
            m_refs.OnTypeReferenceRemoved += new TypeReferenceEventHandler(OnTypeReferenceRemoved);
            m_members = new MemberReferenceCollection(this);

            m_controller = new ReflectionController(this);
        }
Exemplo n.º 3
0
 public virtual void VisitMemberReferenceCollection(MemberReferenceCollection members)
 {
 }
		public MemberReference GetMemberReference (MemberReferenceCollection members, MemberReference member)
		{
			foreach (MemberReference mr in members) {
				if (mr.ToString () == member.ToString ())
					return mr;
			}
			return null;
		}
		bool MemberReferencesContains (MemberReferenceCollection members, MemberReference member)
		{
			MemberReference mr = GetMemberReference (members, member);
			return mr != null;
		}
		public override void VisitMemberReferenceCollection (MemberReferenceCollection members)
		{
			foreach (MemberReference mr in members)
				VisitMemberReference (mr);
		}
Exemplo n.º 7
0
        public override void VisitMemberReferenceCollection(MemberReferenceCollection members)
        {
            if (members.Count == 0)
                return;

            MemberRefTable mrTable = m_tableWriter.GetMemberRefTable ();
            foreach (MemberReference member in members) {
                uint sig = 0;
                if (member is FieldReference)
                    sig = m_sigWriter.AddFieldSig (GetFieldSig (member as FieldReference));
                else if (member is MethodReference)
                    sig = m_sigWriter.AddMethodRefSig (GetMethodRefSig (member as MethodReference));
                MemberRefRow mrRow = m_rowWriter.CreateMemberRefRow (
                    GetTypeDefOrRefToken (member.DeclaringType),
                    m_mdWriter.AddString (member.Name),
                    sig);

                mrTable.Rows.Add (mrRow);
                member.MetadataToken = new MetadataToken (
                    TokenType.MemberRef, (uint) mrTable.Rows.Count);
                }
        }
        public virtual void VisitMemberReferenceCollection(MemberReferenceCollection members)
        {

        }
Exemplo n.º 9
0
        internal ModuleDefinition(string name, AssemblyDefinition asm, StructureReader reader, bool main)
            : base(name)
        {
            if (asm == null)
                throw new ArgumentNullException ("asm");
            if (name == null || name.Length == 0)
                throw new ArgumentNullException ("name");

            m_asm = asm;
            m_main = main;
            #if !CF_1_0
            m_mvid = Guid.NewGuid ();
            #endif
            if (reader != null) {
                m_image = reader.Image;
                m_imgReader = reader.ImageReader;
                m_manifestOnly = reader.ManifestOnly;
            } else
                m_image = Image.CreateImage ();

            m_modRefs = new ModuleReferenceCollection (this);
            m_asmRefs = new AssemblyNameReferenceCollection (this);
            m_res = new ResourceCollection (this);
            m_types = new TypeDefinitionCollection (this);
            m_types.OnTypeDefinitionAdded += new TypeDefinitionEventHandler (OnTypeDefinitionAdded);
            m_types.OnTypeDefinitionRemoved += new TypeDefinitionEventHandler (OnTypeDefinitionRemoved);
            m_refs = new TypeReferenceCollection (this);
            m_refs.OnTypeReferenceAdded += new TypeReferenceEventHandler (OnTypeReferenceAdded);
            m_refs.OnTypeReferenceRemoved += new TypeReferenceEventHandler (OnTypeReferenceRemoved);
            m_members = new MemberReferenceCollection (this);

            m_controller = new ReflectionController (this);
        }
 public virtual void VisitMemberReferenceCollection(MemberReferenceCollection members)
 {
     foreach (MemberReference memberRef in members)
     {
         VisitMemberReference(memberRef);
     }
 }
		static void CheckMemberReferenceDuplicates (MemberReferenceCollection references)
		{
			List<string> names = new List<string> ();
			foreach (MemberReference reference in references) {
				Assert.IsFalse (names.Contains (reference.ToString ()));
				names.Add (reference.ToString ());
			}
		}