Exemplo n.º 1
0
        public static DomainOperator Create(string domainName)
        {
            var result = new DomainOperator();

            result._domain = DomainManagment.Create(domainName);
            return(result);
        }
Exemplo n.º 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

            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;
        }
Exemplo n.º 3
0
        public static void Delete(string name)
        {
            var domain = DomainManagment.Get(name);

            if (domain != null)
            {
                domain.Dispose();
            }
        }
Exemplo n.º 4
0
 public static NDomain Create(string domainName, ComplierResultTarget target = ComplierResultTarget.Stream, ComplierResultError error = ComplierResultError.None)
 {
     if (domainName == default || domainName.ToLower() == "default")
     {
         return(Create(DomainManagment.Default, target, error));
     }
     else
     {
         return(Create(DomainManagment.Create(domainName), target, error));
     }
 }
Exemplo n.º 5
0
        public static NDomain Create(string name = default)
        {
            NDomain domain = new NDomain();

            if (name == default)
            {
                domain._domain = DomainManagment.Create("N" + Guid.NewGuid().ToString("N"));
            }
            else
            {
                domain._domain = DomainManagment.Create(name);
            }

            return(domain);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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>();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 创建一个程序集操作类
        /// </summary>
        /// <param name="domainName">域名,为空使用系统域</param>
        /// <param name="complieInFile">是否将动态内容编译成DLL</param>
        /// <returns></returns>
        public static NAssembly Create(string domainName = default, bool complieInFile = false)
        {
            NAssembly instance = new NAssembly();

            instance.Options.ComplieInFile = complieInFile;


            if (domainName == default)
            {
                instance.Options.Domain = DomainManagment.Default;
            }
            else
            {
                instance.Options.Domain = DomainManagment.Create(domainName);
            }

            return(instance);
        }
Exemplo n.º 9
0
        public static DomainOperator Create(string domainName = default, bool complieInFile = false)
        {
            DomainOperator instance = new DomainOperator
            {
                _complieInFile = complieInFile
            };


            if (domainName == default)
            {
                instance._domain = DomainManagment.Default;
            }
            else
            {
                instance._domain = DomainManagment.Create(domainName);
            }

            return(instance);
        }
Exemplo n.º 10
0
 public static DomainOperator operator +(string domainName, DomainOperator @operator)
 {
     @operator._domain = DomainManagment.Create(domainName);
     return(@operator);
 }
Exemplo n.º 11
0
 public static DomainOperator operator +(DomainOperator @operator, string domainName)
 {
     @operator.Complier.Domain = DomainManagment.Create(domainName);
     return(@operator);
 }