コード例 #1
0
            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);
            }
コード例 #2
0
        /// <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);
        }