當前位置: 首頁>>代碼示例>>C#>>正文


C# Machine.GetGlobalObject方法代碼示例

本文整理匯總了C#中System.Machine.GetGlobalObject方法的典型用法代碼示例。如果您正苦於以下問題:C# Machine.GetGlobalObject方法的具體用法?C# Machine.GetGlobalObject怎麽用?C# Machine.GetGlobalObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Machine的用法示例。


在下文中一共展示了Machine.GetGlobalObject方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CompileAndExecuteTwoSimpleCommand

 public void CompileAndExecuteTwoSimpleCommand()
 {
     ModelParser parser = new ModelParser("a := 1. b := 2");
     this.compiler.CompileExpressions(parser.ParseExpressions());
     Machine machine = new Machine();
     this.block.Execute(machine, null);
     Assert.AreEqual(1, machine.GetGlobalObject("a"));
     Assert.AreEqual(2, machine.GetGlobalObject("b"));
 }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:9,代碼來源:BytecodeCompilerTests.cs

示例2: CreateRemotingAndClientServerAndExecuteCommand

 public void CreateRemotingAndClientServerAndExecuteCommand()
 {
     Machine machine = new Machine();
     RemotingHostServer server = new RemotingHostServer(machine, 10003, "Server3");
     Machine machine2 = new Machine();
     RemotingHostClient client = new RemotingHostClient("localhost", 10003, "Server3");
     client.Execute("aNumber := 3");
     Assert.AreEqual(3, machine.GetGlobalObject("aNumber"));
     Assert.IsNull(machine2.GetGlobalObject("aNumber"));
     server.Stop();
 }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:11,代碼來源:RemotingTests.cs

示例3: SerializeDeserializeClassWithInstanceMethod

        public void SerializeDeserializeClassWithInstanceMethod()
        {
            Machine machine = new Machine();
            IClass klass = machine.CreateClass("MyClass");
            Method method = (new VmCompiler()).CompileInstanceMethod("add: x to: y ^x + y", klass);
            klass.DefineInstanceMethod(method);

            machine = new Machine();
            Assert.IsNotNull(machine.GetGlobalObject("UndefinedObject"));
            Assert.IsNull(machine.GetGlobalObject("MyClass"));

            var result = this.Process(klass, machine);
            var undefined = machine.GetGlobalObject("UndefinedObject");

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(BaseClass));

            var bclass = (BaseClass)result;

            Assert.AreEqual("MyClass", bclass.Name);
            var bmethod = bclass.GetInstanceMethod("add:to:");
            Assert.IsNotNull(bmethod);
        }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:23,代碼來源:ImageSerializerTests.cs

示例4: CreateRemotingAndClientServerAndExportClass

 public void CreateRemotingAndClientServerAndExportClass()
 {
     Loader loader = new Loader(@"DefineRectangleWithNewAndInitialize.st", new SimpleCompiler());
     Machine machine = new Machine(true);
     RemotingHostServer server = new RemotingHostServer(machine, 10004, "Server4");
     Machine machine2 = new Machine(true);
     loader.LoadAndExecute(machine2);
     BaseClass rect = (BaseClass)machine2.GetGlobalObject("Rectangle");
     RemotingHostClient client = new RemotingHostClient("localhost", 10004, "Server4");
     client.Execute(rect.ToOutputString());
     object result = machine.GetGlobalObject("Rectangle");
     Assert.IsNotNull(result);
     Assert.IsInstanceOfType(result, typeof(BaseClass));
     object newresult = client.Evaluate("Rectangle new");
     Assert.IsNotNull(newresult);
     Assert.IsInstanceOfType(newresult, typeof(IObject));
     IObject newrect = (IObject)newresult;
     Assert.AreSame(rect, newrect.Behavior);
     Assert.AreEqual(10, newrect[0]);
     Assert.AreEqual(20, newrect[1]);
     server.Stop();
 }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:22,代碼來源:RemotingTests.cs

示例5: ExecuteTrueIfTrueIfFalse

        public void ExecuteTrueIfTrueIfFalse()
        {
            Machine machine = new Machine();

            ModelParser parser = new ModelParser("true ifTrue: [GlobalName := 'bar'] ifFalse: [GlobalName := 'foo']");
            this.compiler.CompileExpression(parser.ParseExpression());

            this.block.Execute(machine, null);

            Assert.AreEqual("bar", machine.GetGlobalObject("GlobalName"));
        }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:11,代碼來源:BytecodeCompilerTests.cs

示例6: ExecuteBlock

        public void ExecuteBlock()
        {
            Machine machine = new Machine();

            object nil = machine.UndefinedObjectClass;

            Assert.IsNotNull(nil);
            Assert.IsInstanceOfType(nil, typeof(IClass));

            ModelParser parser = new ModelParser("nil ifNil: [GlobalName := 'foo']");
            this.compiler.CompileExpression(parser.ParseExpression());

            this.block.Execute(machine, null);

            Assert.IsNotNull(machine.GetGlobalObject("GlobalName"));
        }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:16,代碼來源:BytecodeCompilerTests.cs

示例7: CompareMachines

        private static void CompareMachines(Machine machine, Machine newmachine)
        {
            Assert.IsNotNull(newmachine.UndefinedObjectClass);
            Assert.IsNotNull(newmachine.GetGlobalObject("UndefinedObject"));
            Assert.AreNotEqual(machine.GetGlobalObject("UndefinedObject"), newmachine.GetGlobalObject("UndefinedObject"));

            var names = machine.GetGlobalNames();
            var newnames = machine.GetGlobalNames();

            Assert.IsNotNull(newnames);
            Assert.AreEqual(names.Count, newnames.Count);

            foreach (var newname in newnames)
                Assert.IsTrue(names.Contains(newname));
        }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:15,代碼來源:ImageSerializerTests.cs

示例8: GetGlobalObjectFromHostMachine

        public void GetGlobalObjectFromHostMachine()
        {
            Machine hostmachine = new Machine();
            IClass hostklass = hostmachine.CreateClass("Rectangle");
            hostmachine.SetGlobalObject(hostklass.Name, hostklass);

            Machine machine = new Machine();
            machine.HostMachine = hostmachine;

            var result = machine.GetGlobalObject("Rectangle");

            Assert.IsNotNull(result);
            Assert.AreSame(hostklass, result);
        }
開發者ID:ajlopez,項目名稱:AjTalk,代碼行數:14,代碼來源:HostMachineTests.cs


注:本文中的System.Machine.GetGlobalObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。