コード例 #1
0
            public RemoteDelegate(ScriptEnvironmentSetup setup)
            {
                ScriptDomainManager local_environment;

                NewCreated  = ScriptDomainManager.TryCreateLocal(setup, out local_environment);
                Environment = new RemoteScriptEnvironment(local_environment);
            }
コード例 #2
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;
 }
コード例 #3
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;
        }
コード例 #4
0
ファイル: ScriptEnvironment.cs プロジェクト: clorton/IDM-CMS
        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);
        }
コード例 #5
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);
            }
コード例 #6
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);
        }
コード例 #7
0
 public RemoteDelegate(ScriptEnvironmentSetup setup) {
     ScriptDomainManager local_environment;
     NewCreated = ScriptDomainManager.TryCreateLocal(setup, out local_environment);
     Environment = new RemoteScriptEnvironment(local_environment);
 }