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


C# Namespace.ElementResolver类代码示例

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


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

示例1: CodeBlockNodeModel

 public CodeBlockNodeModel(LibraryServices libraryServices)
 {
     ArgumentLacing = LacingStrategy.Disabled;
     this.libraryServices = libraryServices;
     this.libraryServices.LibraryLoaded += LibraryServicesOnLibraryLoaded;
     this.ElementResolver = new ElementResolver();
 }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:7,代码来源:CodeBlockNode.cs

示例2: CopyResolutionMap

 public void CopyResolutionMap(ElementResolver otherResolver)
 {
     foreach (var e in otherResolver.ResolutionMap.Where(e => !resolutionMap.ContainsKey(e.Key)))
     {
         resolutionMap.Add(e);
     }
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:7,代码来源:ElementResolver.cs

示例3: GetCompletionsOnType

        /// <summary>
        /// Determines if the completion string is a valid type and 
        /// enumerates the list of completion members on the type
        /// </summary>
        /// <param name="code"> code typed in the code block </param>
        /// <param name="stringToComplete"> Class name or declared variable </param>
        /// <param name="resolver"></param>
        /// <returns> list of method and property members of the type </returns>
        internal IEnumerable<CompletionData> GetCompletionsOnType(string code, string stringToComplete, ElementResolver resolver = null)
        {
            IEnumerable<StaticMirror> members = null;

            if (resolver != null)
            {
                stringToComplete = resolver.LookupResolvedName(stringToComplete) ?? stringToComplete;
            }

            // Determine if the string to be completed is a class
            var type = GetClassType(stringToComplete);
            if (type != null)
            {
                members = type.GetMembers();
            }
            // If not of class type
            else
            {
                // Check if the string to be completed is a declared variable
                string typeName = CodeCompletionParser.GetVariableType(code, stringToComplete);
                if (typeName != null)
                    type = GetClassType(typeName);

                if (type != null)
                {
                    members = type.GetInstanceMembers();
                }
            }

            return members.Select(x => CompletionData.ConvertMirrorToCompletionData(x));
        }
开发者ID:DynamoDS,项目名称:Dynamo,代码行数:39,代码来源:CodeCompletionServices.cs

示例4: LoadNodesFromXml

 private static IEnumerable<NodeModel> LoadNodesFromXml(XmlDocument xmlDoc, NodeFactory nodeFactory, ElementResolver resolver)
 {
     XmlNodeList elNodes = xmlDoc.GetElementsByTagName("Elements");
     if (elNodes.Count == 0)
         elNodes = xmlDoc.GetElementsByTagName("dynElements");
     XmlNode elNodesList = elNodes[0];
     return from XmlElement elNode in elNodesList.ChildNodes
            select LoadNodeFromXml(elNode, SaveContext.File, nodeFactory, resolver);
 }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:9,代码来源:NodeGraph.cs

示例5: 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

示例6: ReproMAGN3603

        public void ReproMAGN3603()
        {

            string code = @"a = 1 + (2 * 3);
                            b = (1 + 2) * 3;
                            c = 1 + 2 * 3;";

            ElementResolver elementResolver = new ElementResolver();
            ParseParam parseParam = new ParseParam(Guid.NewGuid(), code, elementResolver);
            
            Assert.IsTrue(CompilerUtils.PreCompileCodeBlock(thisTest.CreateTestCore(), ref parseParam));
            Assert.IsTrue(parseParam.ParsedNodes != null && parseParam.ParsedNodes.Count() > 0);

            var parsedNode = parseParam.ParsedNodes.ElementAt(0);

            BinaryExpressionNode n = parsedNode as BinaryExpressionNode;
            FunctionCallNode funcCall = n.RightNode as FunctionCallNode;
            Assert.IsTrue(n != null && funcCall != null);
            IdentifierNode identNode = funcCall.Function as IdentifierNode;
            Assert.IsTrue(identNode != null && identNode.Value == "%add");
            var args = funcCall.FormalArguments;
            Assert.IsTrue(args.Count == 2);
            Assert.IsTrue(args[0] is IntNode);
            FunctionCallNode nestedFuncCall = args[1] as FunctionCallNode;
            Assert.IsTrue(nestedFuncCall != null && (nestedFuncCall.Function as IdentifierNode).Value == "%mul");

            parsedNode = parseParam.ParsedNodes.ElementAt(1);

            n = parsedNode as BinaryExpressionNode;
            funcCall = n.RightNode as FunctionCallNode;
            Assert.IsTrue(n != null && funcCall != null);
            identNode = funcCall.Function as IdentifierNode;
            Assert.IsTrue(identNode != null && identNode.Value == "%mul");
            args = funcCall.FormalArguments;
            Assert.IsTrue(args.Count == 2);
            Assert.IsTrue(args[1] is IntNode);
            nestedFuncCall = args[0] as FunctionCallNode;
            Assert.IsTrue(nestedFuncCall != null && (nestedFuncCall.Function as IdentifierNode).Value == "%add");

            parsedNode = parseParam.ParsedNodes.ElementAt(2);

            n = parsedNode as BinaryExpressionNode;
            funcCall = n.RightNode as FunctionCallNode;
            Assert.IsTrue(n != null && funcCall != null);
            identNode = funcCall.Function as IdentifierNode;
            Assert.IsTrue(identNode != null && identNode.Value == "%add");
            args = funcCall.FormalArguments;
            Assert.IsTrue(args.Count == 2);
            Assert.IsTrue(args[0] is IntNode);
            nestedFuncCall = args[1] as FunctionCallNode;
            Assert.IsTrue(nestedFuncCall != null && (nestedFuncCall.Function as IdentifierNode).Value == "%mul");
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:52,代码来源:NewFrontEndTests.cs

示例7: CodeBlockNodeModel

        public CodeBlockNodeModel(string userCode, Guid guid, double xPos, double yPos, LibraryServices libraryServices, ElementResolver resolver)
        {
            ArgumentLacing = LacingStrategy.Disabled;
            X = xPos;
            Y = yPos;
            this.libraryServices = libraryServices;
            this.ElementResolver = resolver;
            code = userCode;
            GUID = guid;
            ShouldFocus = false;

            ProcessCodeDirect();
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:13,代码来源:CodeBlockNode.cs

示例8: TestUnboundIdentifierInUnnamedSignedExpression

        public void TestUnboundIdentifierInUnnamedSignedExpression()
        {
            string code = @"a*-1;";

            ElementResolver elementResolver = new ElementResolver();
            ParseParam parseParam = new ParseParam(Guid.NewGuid(), code, elementResolver);

            Assert.IsTrue(CompilerUtils.PreCompileCodeBlock(thisTest.CreateTestCore(), ref parseParam));
            Assert.IsTrue(parseParam.ParsedNodes != null && parseParam.ParsedNodes.Any());

            var inputIdentifier = parseParam.UnboundIdentifiers;
            Assert.AreEqual(1, inputIdentifier.Count);
            Assert.AreEqual("a", inputIdentifier.ElementAt(0).Value);
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:14,代码来源:NewFrontEndTests.cs

示例9: CustomNodeWorkspaceModel

        public CustomNodeWorkspaceModel( 
            NodeFactory factory,
            IEnumerable<NodeModel> e, 
            IEnumerable<NoteModel> n, 
            IEnumerable<AnnotationModel> a,
            IEnumerable<PresetModel> presets,
            ElementResolver elementResolver, 
            WorkspaceInfo info)
            : base(e, n,a, info, factory,presets, elementResolver)
        {
            HasUnsavedChanges = false;

            CustomNodeId = Guid.Parse(info.ID);
            Category = info.Category;
            Description = info.Description;
            PropertyChanged += OnPropertyChanged;
        }
开发者ID:VinitShukla,项目名称:Dynamo,代码行数:17,代码来源:CustomNodeWorkspaceModel.cs

示例10: CustomNodeWorkspaceModel

        public CustomNodeWorkspaceModel( 
            NodeFactory factory,
            IEnumerable<NodeModel> nodes, 
            IEnumerable<NoteModel> notes, 
            IEnumerable<AnnotationModel> annotations,
            IEnumerable<PresetModel> presets,
            ElementResolver elementResolver, 
            WorkspaceInfo info)
            : base(nodes, notes,annotations, info, factory,presets, elementResolver)
        {
            HasUnsavedChanges = false;

            CustomNodeId = Guid.Parse(info.ID);
            Category = info.Category;
            Description = info.Description;
            IsVisibleInDynamoLibrary = info.IsVisibleInDynamoLibrary;
            PropertyChanged += OnPropertyChanged;
        }
开发者ID:AutodeskFractal,项目名称:Dynamo,代码行数:18,代码来源:CustomNodeWorkspaceModel.cs

示例11: VerifyResult

        private void VerifyResult(string fullName, string partialName, string functionOrProperty, bool isProperty = false)
        {
            var testCore = thisTest.GetTestCore();

            var astNodes = CoreUtils.BuildASTList(testCore, string.Format("d = {0}.{1};", partialName, functionOrProperty));

            var elementResolver = new ElementResolver();

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

            Assert.AreEqual(string.Format("d = {0}.{1};\n", fullName, functionOrProperty), newNodes.ElementAt(0).ToString());

            if (!isProperty)
            {
                // Add verification for contents of element resolver resolution map
                var assembly = elementResolver.LookupAssemblyName(partialName);
                var resolvedName = elementResolver.LookupResolvedName(partialName);

                Assert.AreEqual("FFITarget.dll", assembly);
                Assert.AreEqual(fullName, resolvedName);
            }
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:22,代码来源:ElementRewriterTests.cs

示例12: CustomNodeWorkspaceModel

        public CustomNodeWorkspaceModel( 
            NodeFactory factory, 
            IEnumerable<NodeModel> e, 
            IEnumerable<NoteModel> n, 
            IEnumerable<AnnotationModel> a,
            WorkspaceInfo info,
            ElementResolver elementResolver = null) 
            : base(e, n,a,info, factory)

        {
            HasUnsavedChanges = false;

            CustomNodeId = Guid.Parse(info.ID);
            Category = info.Category;
            Description = info.Description;

            if (elementResolver != null)
            {
                ElementResolver.CopyResolutionMap(elementResolver);
            }

            PropertyChanged += OnPropertyChanged;
        }
开发者ID:junmendoza,项目名称:Dynamo,代码行数:23,代码来源:CustomNodeWorkspaceModel.cs

示例13: LookupResolvedName_FromCompiler_RewriteAst

        public void LookupResolvedName_FromCompiler_RewriteAst()
        {

            const string code = @"import (""FFITarget.dll"");";
            var mirror = thisTest.RunScriptSource(code);

            var testCore = thisTest.GetTestCore();
            var astNodes = CoreUtils.BuildASTList(testCore, "d = ElementResolverTarget.ElementResolverTarget();");

            var elementResolver = new ElementResolver();

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

            Assert.AreEqual("d = FFITarget.ElementResolverTarget.ElementResolverTarget();\n", newNodes.ElementAt(0).ToString());

            // Add verification for contents of element resolver resolution map
            Assert.AreEqual(1, elementResolver.ResolutionMap.Count);

            var assembly = elementResolver.LookupAssemblyName("ElementResolverTarget");
            var resolvedName = elementResolver.LookupResolvedName("ElementResolverTarget");

            Assert.AreEqual("FFITarget.dll", assembly);
            Assert.AreEqual("FFITarget.ElementResolverTarget", resolvedName);
        }
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:24,代码来源:ElementRewriterTests.cs

示例14: DeserializeCore

        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            base.DeserializeCore(nodeElement, context);
            var helper = new XmlElementHelper(nodeElement);
            shouldFocus = helper.ReadBoolean("ShouldFocus");
            code = helper.ReadString("CodeText");

            // Lookup namespace resolution map if available and initialize new instance of ElementResolver
            var resolutionMap = CodeBlockUtils.DeserializeElementResolver(nodeElement);
            ElementResolver = new ElementResolver(resolutionMap);

            ProcessCodeDirect();
        }
开发者ID:RevitLution,项目名称:Dynamo,代码行数:13,代码来源:CodeBlockNode.cs

示例15: WorkspaceModel

        protected WorkspaceModel(
            IEnumerable<NodeModel> e, 
            IEnumerable<NoteModel> n,
            IEnumerable<AnnotationModel> a,
            WorkspaceInfo info, 
            NodeFactory factory,
            IEnumerable<PresetModel> presets)
        {
            guid = Guid.NewGuid();

            nodes = new ObservableCollection<NodeModel>(e);
            notes = new ObservableCollection<NoteModel>(n);

            annotations = new ObservableCollection<AnnotationModel>(a);         

            // Set workspace info from WorkspaceInfo object
            Name = info.Name;
            X = info.X;
            Y = info.Y;
            FileName = info.FileName;
            Zoom = info.Zoom;

            HasUnsavedChanges = false;
            LastSaved = DateTime.Now;

            WorkspaceVersion = AssemblyHelper.GetDynamoVersion();
            undoRecorder = new UndoRedoRecorder(this);

            NodeFactory = factory;

            this.presets = new List<PresetModel>(presets);
            // Update ElementResolver from nodeGraph.Nodes (where node is CBN)
            ElementResolver = new ElementResolver();
            foreach (var node in nodes)
            {
                RegisterNode(node);

                var cbn = node as CodeBlockNodeModel;
                if (cbn != null && cbn.ElementResolver != null)
                {
                    ElementResolver.CopyResolutionMap(cbn.ElementResolver);
                }
            }

            foreach (var connector in Connectors)
                RegisterConnector(connector);

            SetModelEventOnAnnotation();
        }
开发者ID:ke-yu,项目名称:Dynamo,代码行数:49,代码来源:WorkspaceModel.cs


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