public static bool Invoke(AppDomain domain, ScriptEnvironmentSetup setup, out RemoteScriptEnvironment environment) { RemoteDelegate rd = (RemoteDelegate)domain.CreateInstanceAndUnwrap(typeof(RemoteDelegate).Assembly.FullName, typeof(RemoteDelegate).FullName, false, BindingFlags.Default, null, new object[] { setup }, null, null, null); environment = rd.Environment; return rd.NewCreated; }
public RemoteDelegate(ScriptEnvironmentSetup setup) { ScriptDomainManager local_environment; NewCreated = ScriptDomainManager.TryCreateLocal(setup, out local_environment); Environment = new RemoteScriptEnvironment(local_environment); }
public static IScriptEnvironment Create(ScriptEnvironmentSetup setup) { ScriptDomainManager manager; if (!ScriptDomainManager.TryCreateLocal(setup, out manager)) throw new InvalidOperationException("Environment already created in the current AppDomain"); return manager.Environment; }
public static bool Invoke(AppDomain domain, ScriptEnvironmentSetup setup, out RemoteScriptEnvironment environment) { RemoteDelegate rd = (RemoteDelegate)domain.CreateInstanceAndUnwrap(typeof(RemoteDelegate).Assembly.FullName, typeof(RemoteDelegate).FullName, false, BindingFlags.Default, null, new object[] { setup }, null, null, null); environment = rd.Environment; return(rd.NewCreated); }
protected virtual void Initialize() { // A console application needs just the simple setup. // The full setup is potentially expensive as it can involve loading System.Configuration.dll ScriptEnvironmentSetup setup = new ScriptEnvironmentSetup(true); ScriptDomainManager manager; ScriptDomainManager.TryCreateLocal(setup, out manager); }
public void Page_Loaded(object o, EventArgs e) { //InitializeComponent(); Keggy.Scripting.ScriptEngine.Initialize(); ScriptEnvironmentSetup setup = new ScriptEnvironmentSetup(true); setup.PALType = typeof(SilverlightPAL); ScriptEnvironment.Create(setup); }
public static IScriptEnvironment Create(ScriptEnvironmentSetup setup) { ScriptDomainManager manager; if (!ScriptDomainManager.TryCreateLocal(setup, out manager)) { throw new InvalidOperationException("Environment already created in the current AppDomain"); } return(manager.Environment); }
/// <summary> /// Creates a new <see cref="RemoteScriptEnvironment"/> in a specified AppDomain unless it already exists. /// Returns either <c>false</c> and a remote reference to the newly created environment initialized according /// to the provided setup information or <c>true</c> and the existing one ignoring the specified setup information. /// </summary> internal static bool TryCreate(AppDomain domain, ScriptEnvironmentSetup setup, out RemoteScriptEnvironment environment) { Contract.RequiresNotNull(domain, "domain"); // TODO: should be retrieved later in local.trycreate if (setup == null) setup = new ScriptEnvironmentSetup(true); // prepare remote stub for the host: setup.RemoteHost = new RemoteScriptHost(); bool new_created = RemoteDelegate.Invoke(domain, setup, out environment); if (new_created) { // create host local to the caller (i.e. remote to the environment): setup.RemoteHost.SetLocalHost(setup.CreateHostLocally(environment)); } return new_created; }
public static IScriptEnvironment Create(ScriptEnvironmentSetup setup, AppDomain domain) { Contract.RequiresNotNull(domain, "domain"); if (domain == AppDomain.CurrentDomain) { return(Create(setup)); } RemoteScriptEnvironment rse; if (!RemoteScriptEnvironment.TryCreate(domain, setup, out rse)) { throw new InvalidOperationException("Environment already created in the specified AppDomain"); } return(rse); }
/// <summary> /// Creates a new <see cref="RemoteScriptEnvironment"/> in a specified AppDomain unless it already exists. /// Returns either <c>false</c> and a remote reference to the newly created environment initialized according /// to the provided setup information or <c>true</c> and the existing one ignoring the specified setup information. /// </summary> internal static bool TryCreate(AppDomain domain, ScriptEnvironmentSetup setup, out RemoteScriptEnvironment environment) { Contract.RequiresNotNull(domain, "domain"); // TODO: should be retrieved later in local.trycreate if (setup == null) { setup = new ScriptEnvironmentSetup(true); } // prepare remote stub for the host: setup.RemoteHost = new RemoteScriptHost(); bool new_created = RemoteDelegate.Invoke(domain, setup, out environment); if (new_created) { // create host local to the caller (i.e. remote to the environment): setup.RemoteHost.SetLocalHost(setup.CreateHostLocally(environment)); } return(new_created); }
public RemoteDelegate(ScriptEnvironmentSetup setup) { ScriptDomainManager local_environment; NewCreated = ScriptDomainManager.TryCreateLocal(setup, out local_environment); Environment = new RemoteScriptEnvironment(local_environment); }
public static IScriptEnvironment Create(ScriptEnvironmentSetup setup, AppDomain domain) { Contract.RequiresNotNull(domain, "domain"); if (domain == AppDomain.CurrentDomain) { return Create(setup); } RemoteScriptEnvironment rse; if (!RemoteScriptEnvironment.TryCreate(domain, setup, out rse)) throw new InvalidOperationException("Environment already created in the specified AppDomain"); return rse; }