本文整理汇总了C#中System.Machine.CreateNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# Machine.CreateNamespace方法的具体用法?C# Machine.CreateNamespace怎么用?C# Machine.CreateNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Machine
的用法示例。
在下文中一共展示了Machine.CreateNamespace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareToOtherVariables
public void CompareToOtherVariables()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
machine.CreateNamespace("bar");
Variable variableBar = Variable.Intern(machine, "bar", "bar");
Variable variableFooBar = Variable.Intern(machine, "foo", "bar");
Variable variableBarFoo = Variable.Intern(machine, "bar", "foo");
Assert.AreEqual(0, variableBar.CompareTo(variableBar));
Assert.AreEqual(0, variableFooBar.CompareTo(variableFooBar));
Assert.AreEqual(-1, variableBar.CompareTo(variableFooBar));
Assert.AreEqual(1, variableFooBar.CompareTo(variableBar));
Assert.AreEqual(1, variableFooBar.CompareTo(variableBarFoo));
Assert.AreEqual(-1, variableBarFoo.CompareTo(variableFooBar));
}
示例2: BeNotEqualToVariableWithOtherName
public void BeNotEqualToVariableWithOtherName()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable variable = Variable.Intern(machine, "foo/bar");
Variable variable2 = Variable.Intern(machine, "foo/bar2");
Assert.AreNotEqual(variable, variable2);
}
示例3: BeEqualToVariableWithSameNameAndNamespace
public void BeEqualToVariableWithSameNameAndNamespace()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable variable = Variable.Intern(machine, "foo", "bar");
Variable variable2 = Variable.Intern(machine, "foo", "bar");
Assert.AreEqual(variable, variable2);
Assert.AreEqual(variable.GetHashCode(), variable2.GetHashCode());
}
示例4: BeEquals
public void BeEquals()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable var1 = Variable.Intern(machine, "foo", "bar");
Variable var2 = Variable.Intern(machine, "foo", "bar");
Variable var3 = Variable.Intern(machine, "foo/bar");
Assert.IsTrue(var1.Equals(var2));
Assert.IsTrue(var2.Equals(var1));
Assert.IsTrue(var1.Equals(var3));
Assert.IsTrue(var3.Equals(var1));
Assert.IsTrue(var2.Equals(var3));
Assert.IsTrue(var3.Equals(var2));
}
示例5: CreateAVariable
public void CreateAVariable()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable var = Variable.Intern(machine, "foo", "bar");
Assert.IsNotNull(var);
Assert.AreEqual("foo", var.Namespace);
Assert.AreEqual("bar", var.Name);
Assert.AreEqual(Utilities.GetFullName("foo", "bar"), var.FullName);
Variable var2 = Variable.Intern(machine, "foo", "bar");
Assert.IsNotNull(var2);
Assert.IsTrue(var.Equals(var2));
}
示例6: SetMacroOnDefinedMultiFunction
public void SetMacroOnDefinedMultiFunction()
{
Machine machine = new Machine();
machine.CreateNamespace("ns");
FnStarPrimitive fnprim = new FnStarPrimitive();
Parser parser = new Parser("([x] (+ x 1)) ([x y] (+ x y 1))");
object[] parameters = new object[2];
parameters[0] = parser.ParseForm();
parameters[1] = parser.ParseForm();
object result = fnprim.Apply(machine, machine.Environment, parameters);
DefinedMultiFunction multifn = (DefinedMultiFunction)result;
Variable variable = Variable.Intern(machine, "ns/func");
machine.SetVariableValue(variable, multifn);
variable.SetMacro(machine);
object mresult = machine.GetVariableValue(variable);
Assert.IsNotNull(mresult);
Assert.IsInstanceOfType(mresult, typeof(DefinedMultiMacro));
}
示例7: SetMacroOnDefinedFunction
public void SetMacroOnDefinedFunction()
{
Machine machine = new Machine();
machine.CreateNamespace("ns");
Variable variable = Variable.Intern(machine, "ns/func");
Parser parser = new Parser("[x y] (list x y) 1 2");
object argumentNames = parser.ParseForm();
object body = parser.ParseForm();
DefinedFunction func = new DefinedFunction("simple-list", (ICollection)argumentNames, Utilities.ToExpression(body));
machine.SetVariableValue(variable, func);
variable.SetMacro(machine);
object result = machine.GetVariableValue(variable);
Assert.IsNotNull(result);
Assert.IsInstanceOfType(result, typeof(DefinedMacro));
}
示例8: ResetVariableMetadata
public void ResetVariableMetadata()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable variable = Variable.Intern(machine, "foo/bar");
variable.ResetMetadata(FakePersistentMap.Instance);
Assert.IsNotNull(variable.Metadata);
Assert.IsTrue(variable.Metadata == FakePersistentMap.Instance);
}
示例9: CreateWithNameAndNamespace
public void CreateWithNameAndNamespace()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable variable = Variable.Intern(machine, "foo", "bar");
Assert.IsNotNull(variable);
Assert.AreEqual("foo", variable.Namespace);
Assert.AreEqual("bar", variable.Name);
Assert.AreEqual("foo/bar", variable.FullName);
}
示例10: CreateVariableWithNullMetadata
public void CreateVariableWithNullMetadata()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable variable = Variable.Intern(machine, "foo/bar");
IObject iobj = variable.WithMetadata(null);
Assert.IsNotNull(iobj);
Assert.IsTrue(variable == iobj);
}
示例11: CreateVariableWithMetadata
public void CreateVariableWithMetadata()
{
Machine machine = new Machine();
machine.CreateNamespace("foo");
Variable variable = Variable.Intern(machine, "foo/bar");
IObject iobj = variable.WithMetadata(FakePersistentMap.Instance);
Assert.IsNotNull(iobj);
Assert.IsTrue(variable != iobj);
Assert.IsNotNull(iobj.Metadata);
Assert.IsTrue(iobj.Metadata == FakePersistentMap.Instance);
}