Esempio n. 1
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="arrayType">Array type</param>
 /// <param name="rank">Array rank</param>
 /// <param name="sizes">Sizes list. <c>This instance will be the owner of this list.</c></param>
 /// <param name="lowerBounds">Lower bounds list. <c>This instance will be the owner of this list.</c></param>
 public ArraySig(TypeSig arrayType, uint rank, ThreadSafe.IEnumerable <uint> sizes, ThreadSafe.IEnumerable <int> lowerBounds)
     : base(arrayType)
 {
     this.rank   = rank;
     Sizes       = ThreadSafeListCreator.Create(sizes);
     LowerBounds = ThreadSafeListCreator.Create(lowerBounds);
 }
        /// <summary>
        ///     Finds an assembly that exactly matches the requested assembly
        /// </summary>
        /// <param name="assembly">Assembly to find</param>
        /// <param name="paths">Search paths or <c>null</c> if none</param>
        /// <param name="moduleContext">Module context</param>
        /// <returns>
        ///     An <see cref="AssemblyDef" /> instance or <c>null</c> if an exact match
        ///     couldn't be found.
        /// </returns>
        private AssemblyDef FindExactAssembly(IAssembly assembly, ThreadSafe.IEnumerable <string> paths, ModuleContext moduleContext)
        {
            if (paths == null)
            {
                return(null);
            }
            var asmComparer = AssemblyNameComparer.CompareAll;

            foreach (var path in paths.GetSafeEnumerable())
            {
                ModuleDefMD mod = null;
                try
                {
                    mod = ModuleDefMD.Load(path, moduleContext);
                    var asm = mod.Assembly;
                    if (asm != null && asmComparer.Equals(assembly, asm))
                    {
                        mod = null;
                        return(asm);
                    }
                }
                catch
                {
                }
                finally
                {
                    if (mod != null)
                    {
                        mod.Dispose();
                    }
                }
            }
            return(null);
        }
Esempio n. 3
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="locals">All locals that will be owned by this instance</param>
 public LocalList(ThreadSafe.IEnumerable <Local> locals)
 {
     this.locals = new LazyList <Local>(this);
     foreach (var local in locals.GetSafeEnumerable())
     {
         this.locals.Add(local);
     }
 }
        /// <summary>
        ///     Constructor
        /// </summary>
        /// <param name="ctor">Custom attribute constructor</param>
        /// <param name="arguments">Constructor arguments or <c>null</c> if none</param>
        /// <param name="namedArguments">Named arguments or <c>null</c> if none</param>
        /// <param name="blobReader">A reader that returns the original custom attribute blob data</param>
        public CustomAttribute(ICustomAttributeType ctor, ThreadSafe.IEnumerable <CAArgument> arguments, ThreadSafe.IEnumerable <CANamedArgument> namedArguments, IBinaryReader blobReader)
        {
            Constructor          = ctor;
            ConstructorArguments = arguments == null?ThreadSafeListCreator.Create <CAArgument>() : ThreadSafeListCreator.Create(arguments);

            NamedArguments = namedArguments == null?ThreadSafeListCreator.Create <CANamedArgument>() : ThreadSafeListCreator.Create(namedArguments);

            this.blobReader = blobReader;
        }
 private ThreadSafe.IEnumerable <string> FindAssemblies2(IAssembly assembly, ThreadSafe.IEnumerable <string> paths)
 {
     if (paths != null)
     {
         var asmSimpleName = UTF8String.ToSystemStringOrEmpty(assembly.Name);
         var exts          = assembly.IsContentTypeWindowsRuntime ? winMDAssemblyExtensions : assemblyExtensions;
         foreach (var ext in exts)
         {
             foreach (var path in paths.GetSafeEnumerable())
             {
                 var fullPath = Path.Combine(path, asmSimpleName + ext);
                 if (File.Exists(fullPath))
                 {
                     yield return(fullPath);
                 }
             }
         }
     }
 }
        private AssemblyDef FindClosestAssembly(IAssembly assembly, AssemblyDef closest, ThreadSafe.IEnumerable <string> paths, ModuleContext moduleContext)
        {
            if (paths == null)
            {
                return(closest);
            }
            var asmComparer = AssemblyNameComparer.CompareAll;

            foreach (var path in paths.GetSafeEnumerable())
            {
                ModuleDefMD mod = null;
                try
                {
                    mod = ModuleDefMD.Load(path, moduleContext);
                    var asm = mod.Assembly;
                    if (asm != null && asmComparer.CompareClosest(assembly, closest, asm) == 1)
                    {
                        if (!IsCached(closest) && closest != null)
                        {
                            var closeMod = closest.ManifestModule;
                            if (closeMod != null)
                            {
                                closeMod.Dispose();
                            }
                        }
                        closest = asm;
                        mod     = null;
                    }
                }
                catch
                {
                }
                finally
                {
                    if (mod != null)
                    {
                        mod.Dispose();
                    }
                }
            }

            return(closest);
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="rva">RVA of this vtable</param>
 /// <param name="flags">Flgas</param>
 /// <param name="methods">Vtable methods</param>
 public VTable(RVA rva, VTableFlags flags, ThreadSafe.IEnumerable <IMethod> methods)
 {
     RVA     = rva;
     Flags   = flags;
     Methods = ThreadSafeListCreator.Create(methods);
 }
Esempio n. 8
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="arrayType">Array type</param>
 /// <param name="rank">Array rank</param>
 /// <param name="sizes">Sizes list. <c>This instance will be the owner of this list.</c></param>
 /// <param name="lowerBounds">Lower bounds list. <c>This instance will be the owner of this list.</c></param>
 public ArraySig(TypeSig arrayType, int rank, ThreadSafe.IEnumerable <uint> sizes, ThreadSafe.IEnumerable <int> lowerBounds)
     : this(arrayType, (uint)rank, sizes, lowerBounds)
 {
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="ctor">Custom attribute constructor</param>
 /// <param name="arguments">Constructor arguments or <c>null</c> if none</param>
 /// <param name="namedArguments">Named arguments or <c>null</c> if none</param>
 public CustomAttribute(ICustomAttributeType ctor, ThreadSafe.IEnumerable <CAArgument> arguments, ThreadSafe.IEnumerable <CANamedArgument> namedArguments)
     : this(ctor, arguments, namedArguments, null)
 {
 }