当前位置: 首页>>代码示例>>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;未经允许,请勿转载。