// Constructor private ScriptDomain(string name) { // Store the domain instance domain = this; // Create the app domain sandbox = AppDomain.CurrentDomain; // Create a security checker checker = new AssemblyChecker(); }
/// <summary> /// Creates a new <see cref="ScriptDomain"/> into which assemblies and scripts may be loaded. /// </summary> /// <returns>A new instance of <see cref="ScriptDomain"/></returns> public static ScriptDomain CreateDomain(string domainName, bool initCompiler) { // Create a new named domain ScriptDomain domain = new ScriptDomain("DynamicCSharp"); // Check for compiler if (initCompiler == true) { domain.CreateCompilerService(); } return(domain); }
// Constructor /// <summary> /// Create a new <see cref="ScriptEvaluator"/> that is able to execute C# code outside of a method body. /// </summary> /// <param name="domain">The domain that the evaluated code should run under. If null is passed then the active domain is used. The domain must have an active <see cref="Compiler.ScriptCompiler"/></param> /// <exception cref="ArgumentNullException">The specified domain is null and there is no active global domain</exception> /// <exception cref="ArgumentException">The specified domain does not have a compiler service initialized and is unable to compile code</exception> public ScriptEvaluator(ScriptDomain domain = null) { // Use active domain if null is supplied if (domain == null) { domain = ScriptDomain.Active; } // Check for domain if (domain == null) { throw new ArgumentNullException("The specified domain was null and there are no active domains"); } // Check for compiler if (domain.CompilerService == null) { throw new ArgumentException("The specified domain does not have a compiler service registered. The compiler service is required by a ScriptEvaluator"); } // Cache the domain this.domain = domain; }
// Constructor internal AsyncCompileLoadOperation(ScriptDomain domain, Func <bool> asyncCallback) : base(domain.CompilerService, asyncCallback) { this.domain = domain; }
// Constructor internal ScriptAssembly(ScriptDomain domain, Assembly rawAssembly) { this.domain = domain; this.rawAssembly = rawAssembly; }