Inheritance: MetaDataMember, IResolutionScope
Exemplo n.º 1
0
 internal TypeSystem(NETHeader netheader)
 {
     this._managedHeader = netheader;
     if (netheader.ParentAssembly._path.StartsWith(@"C:\Windows\Microsoft.NET\Framework") && netheader.ParentAssembly._path.EndsWith("\\mscorlib.dll"))
         _iscorlib = true;
     else
     {
         _mscorlibRef = new AssemblyReference("mscorlib", AssemblyAttributes.None, new Version(), AssemblyHashAlgorithm.None, 0 , null) {_netheader = netheader };
     }
     Void = CreateCorLibTypeRef("System", "Void", ElementType.Void);
     IntPtr = CreateCorLibTypeRef("System", "IntPtr", ElementType.I);
     Int8 = CreateCorLibTypeRef("System", "SByte", ElementType.I1);
     Int16 = CreateCorLibTypeRef("System", "Int16", ElementType.I2);
     Int32 = CreateCorLibTypeRef("System", "Int32", ElementType.I4);
     Int64 = CreateCorLibTypeRef("System", "Int64", ElementType.I8);
     UIntPtr = CreateCorLibTypeRef("System", "UIntPtr", ElementType.U);
     UInt8 = CreateCorLibTypeRef("System", "Byte", ElementType.U1);
     UInt16 = CreateCorLibTypeRef("System", "UInt16", ElementType.U2);
     UInt32 = CreateCorLibTypeRef("System", "UInt32", ElementType.U4);
     UInt64 = CreateCorLibTypeRef("System", "UInt64", ElementType.U8);
     Object = CreateCorLibTypeRef("System", "Object", ElementType.Object);
     Single = CreateCorLibTypeRef("System", "Single", ElementType.R4);
     Double = CreateCorLibTypeRef("System", "Double", ElementType.R8);
     Char = CreateCorLibTypeRef("System", "Char", ElementType.Char);
     String = CreateCorLibTypeRef("System", "String", ElementType.String);
     Type = CreateCorLibTypeRef("System", "Type", ElementType.Type);
     Boolean = CreateCorLibTypeRef("System", "Boolean", ElementType.Boolean);
 }
Exemplo n.º 2
0
 internal TypeSystem(NETHeader netheader)
 {
     this.managedHeader = netheader;
     if (netheader.ParentAssembly.path.StartsWith(@"C:\Windows\Microsoft.NET\Framework") && netheader.ParentAssembly.path.EndsWith("\\mscorlib.dll"))
         iscorlib = true;
     else
     {
         mscorlibref = new AssemblyReference() { name = "mscorlib", netheader = netheader };
         //mscorlibref = netheader.TablesHeap.GetTable( MetaDataTableType.AssemblyRef).Members.First(m => (m as AssemblyReference).Name == "mscorlib") as AssemblyReference;
     }
     Void = CreateCorLibTypeRef("System", "Void", ElementType.Void);
     IntPtr = CreateCorLibTypeRef("System", "IntPtr", ElementType.I);
     Int8 = CreateCorLibTypeRef("System", "SByte", ElementType.I1);
     Int16 = CreateCorLibTypeRef("System", "Int16", ElementType.I2);
     Int32 = CreateCorLibTypeRef("System", "Int32", ElementType.I4);
     Int64 = CreateCorLibTypeRef("System", "Int64", ElementType.I8);
     UIntPtr = CreateCorLibTypeRef("System", "UIntPtr", ElementType.U);
     UInt8 = CreateCorLibTypeRef("System", "Byte", ElementType.U1);
     UInt16 = CreateCorLibTypeRef("System", "UInt16", ElementType.U2);
     UInt32 = CreateCorLibTypeRef("System", "UInt32", ElementType.U4);
     UInt64 = CreateCorLibTypeRef("System", "UInt64", ElementType.U8);
     Object = CreateCorLibTypeRef("System", "Object", ElementType.Object);
     Single = CreateCorLibTypeRef("System", "Single", ElementType.R4);
     Double = CreateCorLibTypeRef("System", "Double", ElementType.R8);
     Char = CreateCorLibTypeRef("System", "Char", ElementType.Char);
     String = CreateCorLibTypeRef("System", "String", ElementType.String);
     Type = CreateCorLibTypeRef("System", "Type", ElementType.Type);
     Boolean = CreateCorLibTypeRef("System", "Boolean", ElementType.Boolean);
 }
Exemplo n.º 3
0
        public virtual Win32Assembly Resolve(AssemblyReference reference)
        {
            Win32Assembly resolvedAssembly = null;
            string name = reference.Name;

            if (reference.HasImage && !string.IsNullOrEmpty(reference.NETHeader.ParentAssembly.Path))
            {
                // Check directory of container assembly.
                TryGetAssembly(Path.GetDirectoryName(reference.NETHeader.ParentAssembly.Path), name, out resolvedAssembly);
            }

            if (resolvedAssembly == null)
            {
                // Check gac directories.
                if (!TryGetAssemblyGac(Path.Combine(_gacDirectory, "GAC_64"), name, out resolvedAssembly))
                    if (!TryGetAssemblyGac(Path.Combine(_gacDirectory, "GAC_32"), name, out resolvedAssembly))
                        TryGetAssemblyGac(Path.Combine(_gacDirectory, "GAC_MSIL"), name, out resolvedAssembly);
            }

            if (resolvedAssembly == null)
            {
                // Check search directories
                foreach (var directory in SearchDirectories)
                {
                    if (TryGetAssembly(directory, name, out resolvedAssembly))
                        break;
                }
            }

            if (resolvedAssembly == null)
                OnResolutionFailed(reference);

            if (resolvedAssembly != null)
                _assemblyCache.Add(reference.Name, resolvedAssembly);

            return resolvedAssembly;
        }
Exemplo n.º 4
0
 public override void LoadCache()
 {
     reference = Reference;
 }
Exemplo n.º 5
0
 public override void ClearCache()
 {
     base.ClearCache();
     reference = null;
 }
Exemplo n.º 6
0
 public AssemblyRefProcessor(uint processor, AssemblyReference asmReference)
     : base(new MetaDataRow(processor, asmReference.TableIndex))
 {
     reference = asmReference;
 }
Exemplo n.º 7
0
 public AssemblyRefOS(uint platformID, uint majorversion, uint minorversion, AssemblyReference asmReference)
     : base(new MetaDataRow(platformID, majorversion, minorversion, asmReference.TableIndex))
 {
     reference = asmReference;
 }
 public override void ClearCache()
 {
     base.ClearCache();
     reference = null;
 }
 public AssemblyRefOS(uint platformID, uint majorversion, uint minorversion, AssemblyReference asmReference)
     : base(new MetaDataRow(platformID, majorversion, minorversion, asmReference.TableIndex))
 {
     reference = asmReference;
 }
 public AssemblyRefProcessor(uint processor, AssemblyReference asmReference)
     : base(new MetaDataRow(processor, asmReference.TableIndex))
 {
     reference = asmReference;
 }
Exemplo n.º 11
0
 private void UpdateAssemblyRef(Workspace workspace, AssemblyReference asmRef)
 {
     // TODO: update public key token (blob)
     asmRef.MetaDataRow.Parts[6] = GetStringIndex(workspace, asmRef.Name);
     asmRef.MetaDataRow.Parts[7] = GetStringIndex(workspace, asmRef.Culture );
     // TODO: serialize blob (hash value).
 }
Exemplo n.º 12
0
 public Win32Assembly ResolveAssembly(AssemblyReference assemblyRef)
 {
     return ResolveAssembly(assemblyRef.Name);
 }
Exemplo n.º 13
0
 public override void LoadCache()
 {
     reference = Reference;
 }
Exemplo n.º 14
0
 protected virtual void OnResolutionFailed(AssemblyReference reference)
 {
     if (ResolutionFailed != null)
         ResolutionFailed(this, reference);
 }