本文整理汇总了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"));
}
示例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();
}
示例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);
}
示例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();
}
示例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"));
}
示例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"));
}
示例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));
}
示例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);
}