public RemoteDelegate(ScriptEnvironmentSetup setup)
            {
                ScriptDomainManager local_environment;

                NewCreated  = ScriptDomainManager.TryCreateLocal(setup, out local_environment);
                Environment = new RemoteScriptEnvironment(local_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;
 }
        /// <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;
        }
Example #4
0
        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);
        }
            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);
            }
        /// <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);
 }