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