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


C# ElementResolver.AddToResolutionMap方法代码示例

本文整理汇总了C#中ProtoCore.Namespace.ElementResolver.AddToResolutionMap方法的典型用法代码示例。如果您正苦于以下问题:C# ElementResolver.AddToResolutionMap方法的具体用法?C# ElementResolver.AddToResolutionMap怎么用?C# ElementResolver.AddToResolutionMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProtoCore.Namespace.ElementResolver的用法示例。


在下文中一共展示了ElementResolver.AddToResolutionMap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LookupResolvedName_FromElementResolver_RewriteAst

        public void LookupResolvedName_FromElementResolver_RewriteAst()
        {
            var astNodes = CoreUtils.BuildASTList(core, "p = Point.ByCoordinates(0,0,0);");

            var elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            var newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p = Autodesk.DS.Geometry.Point.ByCoordinates(0, 0, 0);\n", newNodes.ElementAt(0).ToString());
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:11,代码来源:ElementRewriterTests.cs

示例2: LookupResolvedName_ForFunctionDefinition_RewriteAst

        public void LookupResolvedName_ForFunctionDefinition_RewriteAst()
        {
            var code =
                "def foo()" +
                "{" +
                "   return = Autodesk.DesignScript.Geometry.Point.ByCoordinates();" +
                "}" +
                "a = foo();";
            
            var elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Point", "Autodesk.DesignScript.Geometry.Point", "Protogeometry.dll");

            var astNodes = CoreUtils.BuildASTList(core, code);
            var newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes).ToList();

            Assert.AreEqual("return = Autodesk.DesignScript.Geometry.Point.ByCoordinates();\n", 
                ((FunctionDefinitionNode)newNodes[0]).FunctionBody.ToString());
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:18,代码来源:ElementRewriterTests.cs

示例3: LookupResolvedName_ForPartialTypedIdentifier_RewriteAst

        public void LookupResolvedName_ForPartialTypedIdentifier_RewriteAst()
        {
            var astNodes = CoreUtils.BuildASTList(core, "p : Autodesk.Point;");

            var elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            var newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p : Autodesk.DS.Geometry.Point", newNodes.ElementAt(0).ToString());

            astNodes = CoreUtils.BuildASTList(core, "p : Autodesk.DS.Point;");

            elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.DS.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p : Autodesk.DS.Geometry.Point", newNodes.ElementAt(0).ToString());

            astNodes = CoreUtils.BuildASTList(core, "p : Autodesk.DS.Geometry.Point;");

            elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.DS.Geometry.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p : Autodesk.DS.Geometry.Point", newNodes.ElementAt(0).ToString());
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:29,代码来源:ElementRewriterTests.cs

示例4: LookupResolvedName_ForPartialNestedExpression_RewriteAst

        public void LookupResolvedName_ForPartialNestedExpression_RewriteAst()
        {
            var astNodes = CoreUtils.BuildASTList(core, "p = Autodesk.Point.ByCoordinates(Autodesk.Point.ByCoordinates(x, y, z).X, y, z).X;");

            var elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            var newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p = Autodesk.DS.Geometry.Point.ByCoordinates(Autodesk.DS.Geometry.Point.ByCoordinates(x, y, z).X, y, z).X;\n", newNodes.ElementAt(0).ToString());

            /////////////////////////////////////
            astNodes = CoreUtils.BuildASTList(core, "p = Autodesk.DS.Point.ByCoordinates(Autodesk.Point.ByCoordinates(x, y, z).X, y, z).X;");

            elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");
            elementResolver.AddToResolutionMap("Autodesk.DS.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p = Autodesk.DS.Geometry.Point.ByCoordinates(Autodesk.DS.Geometry.Point.ByCoordinates(x, y, z).X, y, z).X;\n", newNodes.ElementAt(0).ToString());

            //////////////////////////////////////
            astNodes = CoreUtils.BuildASTList(core, "p = Autodesk.DS.Geometry.Point.ByCoordinates(Autodesk.Point.ByCoordinates(x, y, z).X, y, z).X;");

            elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");
            elementResolver.AddToResolutionMap("Autodesk.DS.Geometry.Point", "Autodesk.DS.Geometry.Point", "Protogeometry.dll");

            newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes);

            Assert.AreEqual("p = Autodesk.DS.Geometry.Point.ByCoordinates(Autodesk.DS.Geometry.Point.ByCoordinates(x, y, z).X, y, z).X;\n", newNodes.ElementAt(0).ToString());
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:33,代码来源:ElementRewriterTests.cs

示例5: LookupResolvedName_ForAssociativeBlock_RewriteAst

        public void LookupResolvedName_ForAssociativeBlock_RewriteAst()
        {
            var code =
                "c = [Associative]" +
                "{" +
                "   a = {1, 2, 3, 4};" +
                "   b = Autodesk.Point.ByCoordinates(a);" +
                "   return = b;" +
                "}";

            var elementResolver = new ElementResolver();
            elementResolver.AddToResolutionMap("Autodesk.Point", "Autodesk.DesignScript.Geometry.Point", 
                "Protogeometry.dll");

            var astNodes = CoreUtils.BuildASTList(core, code);
            var newNodes = ElementRewriter.RewriteElementNames(core.ClassTable, elementResolver, astNodes).ToList();

            var lbn = ((BinaryExpressionNode)newNodes[0]).RightNode as LanguageBlockNode;
            Assert.IsNotNull(lbn);

            var cbn = lbn.CodeBlockNode as CodeBlockNode;
            Assert.IsNotNull(cbn);

            Assert.AreEqual("b = Autodesk.DesignScript.Geometry.Point.ByCoordinates(a);\n",
                cbn.Body[1].ToString());
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:26,代码来源:ElementRewriterTests.cs


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