當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。