当前位置: 首页>>代码示例>>C#>>正文


C# Machine.CreateNamespace方法代码示例

本文整理汇总了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));
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:19,代码来源:VariableTests.cs

示例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);
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:10,代码来源:VariableTests.cs

示例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());
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:11,代码来源:VariableTests.cs

示例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));
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:16,代码来源:VariableTests.cs

示例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));
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:17,代码来源:VariableTests.cs

示例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));
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:25,代码来源:VariableTests.cs

示例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));
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:22,代码来源:VariableTests.cs

示例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);
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:12,代码来源:VariableTests.cs

示例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);
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:12,代码来源:VariableTests.cs

示例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);
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:11,代码来源:VariableTests.cs

示例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);
        }
开发者ID:ajlopez,项目名称:AjSharpure,代码行数:14,代码来源:VariableTests.cs


注:本文中的System.Machine.CreateNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。