Beispiel #1
0
        public AssemblyDomain(string key)
#if  !NETSTANDARD2_0
            : base(isCollectible: true, name: key)
#endif

        {
#if !NETSTANDARD2_0
            _resolver = new AssemblyDependencyResolver(AppDomain.CurrentDomain.BaseDirectory);
#else
            Name = key;
#endif

            DomainManagment.Add(key, this);
            TypeCache        = new HashSet <Type>();
            OutfileMapping   = new ConcurrentDictionary <string, Assembly>();
            AssemblyMappings = new ConcurrentDictionary <Assembly, AssemblyUnitInfo>();
            CanCover         = true;


            if (key == "Default")
            {
                var _ref = DependencyContext.Default.CompileLibraries
                           .SelectMany(cl => cl.ResolveReferencePaths())
                           .Select(asm => MetadataReference.CreateFromFile(asm));

                ReferencesCache = new HashSet <PortableExecutableReference>(_ref);
            }
            else
            {
                ReferencesCache = new HashSet <PortableExecutableReference>();
            }


            this.Unloading += AssemblyDomain_Unloading;
        }
Beispiel #2
0
        public AssemblyDomain(string key)

#if  !NETSTANDARD2_0
            : base(isCollectible: true, name: key)
#endif

        {
#if !NETSTANDARD2_0
            _resolver = new AssemblyDependencyResolver(AppDomain.CurrentDomain.BaseDirectory);
#else
            Name = key;
#endif
            ObjLock = new object();


            DomainPath = Path.Combine(IComplier.CurrentPath, key);
            if (!Directory.Exists(DomainPath))
            {
                Directory.CreateDirectory(DomainPath);
            }


            OutfileMapping   = new ConcurrentDictionary <string, Assembly>();
            AssemblyMappings = new ConcurrentDictionary <Assembly, AssemblyUnitInfo>();


            if (key == "Default")
            {
                var _ref = DependencyContext.Default.CompileLibraries
                           .SelectMany(cl => cl.ResolveReferencePaths())
                           .Select(asm => MetadataReference.CreateFromFile(asm));
                ReferencesCache    = new LinkedList <PortableExecutableReference>(_ref);
                Default.Resolving += Default_Resolving;
#if !NETSTANDARD2_0
                Default.ResolvingUnmanagedDll += Default_ResolvingUnmanagedDll;
#endif
            }
            else
            {
                ReferencesCache = new LinkedList <PortableExecutableReference>();
//                this.Resolving += Default_Resolving;
//#if !NETSTANDARD2_0
//                this.ResolvingUnmanagedDll += Default_ResolvingUnmanagedDll;
//#endif
            }
            DomainManagment.Add(key, this);
        }
Beispiel #3
0
        public AssemblyDomain(string key)

#if  !NETSTANDARD2_0
            : base(isCollectible: true, name: key)
#endif

        {
#if !NETSTANDARD2_0
            _load_resolver = new AssemblyDependencyResolver(AppDomain.CurrentDomain.BaseDirectory);
#else
            Name = key;
#endif



            DomainPath             = Path.Combine(IComplier.CurrentPath, key);
            OutfileMapping         = new ConcurrentDictionary <string, Assembly>();
            PathMapping            = new ConcurrentDictionary <Assembly, string>();
            AssemblyMappings       = new ConcurrentDictionary <Assembly, AssemblyUnitInfo>();
            ShortReferenceMappings = new ConcurrentDictionary <string, PortableExecutableReference>();

            DomainManagment.Add(key, this);

            if (key == "Default")
            {
                var _ref = DependencyContext.Default.CompileLibraries
                           .SelectMany(cl => cl.ResolveReferencePaths())
                           .Select(asm =>
                {
                    var table = MetadataReference.CreateFromFile(asm);
                    ShortReferenceMappings[Path.GetFileName(asm)] = table;
                    return(table);
                });


                ReferencesCache    = new LinkedList <PortableExecutableReference>(_ref);
                Default.Resolving += Default_Resolving;
#if !NETSTANDARD2_0
                Default.ResolvingUnmanagedDll += Default_ResolvingUnmanagedDll;
#endif
            }
            else
            {
                ReferencesCache = new LinkedList <PortableExecutableReference>();
            }
        }