public void NodeList() { //ExStart //ExFor:NodeList.Count //ExFor:NodeList.Item(System.Int32) //ExSummary:Shows how to use XPaths to navigate a NodeList. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert some nodes with a DocumentBuilder. builder.Writeln("Hello world!"); builder.StartTable(); builder.InsertCell(); builder.Write("Cell 1"); builder.InsertCell(); builder.Write("Cell 2"); builder.EndTable(); #if NET462 || JAVA builder.InsertImage(Image.FromFile(ImageDir + "Logo.jpg")); #elif NETCOREAPP2_1 || __MOBILE__ using (SKBitmap image = SKBitmap.Decode(ImageDir + "Logo.jpg")) builder.InsertImage(image); #endif // Our document contains three Run nodes. NodeList nodeList = doc.SelectNodes("//Run"); Assert.AreEqual(3, nodeList.Count); Assert.True(nodeList.Any(n => n.GetText().Trim() == "Hello world!")); Assert.True(nodeList.Any(n => n.GetText().Trim() == "Cell 1")); Assert.True(nodeList.Any(n => n.GetText().Trim() == "Cell 2")); // Use a double forward slash to select all Run nodes // that are indirect descendants of a Table node, which would be the runs inside the two cells we inserted. nodeList = doc.SelectNodes("//Table//Run"); Assert.AreEqual(2, nodeList.Count); Assert.True(nodeList.Any(n => n.GetText().Trim() == "Cell 1")); Assert.True(nodeList.Any(n => n.GetText().Trim() == "Cell 2")); // Single forward slashes specify direct descendant relationships, // which we skipped when we used double slashes. Assert.AreEqual(doc.SelectNodes("//Table//Run"), doc.SelectNodes("//Table/Row/Cell/Paragraph/Run")); // Access the shape that contains the image we inserted. nodeList = doc.SelectNodes("//Shape"); Assert.AreEqual(1, nodeList.Count); Shape shape = (Shape)nodeList[0]; Assert.True(shape.HasImage); //ExEnd }
public override PropertyTreeMetaObject StartStep( PropertyTreeMetaObject target, PropertyTreeNavigator self, NodeList children) { if (!(target is UntypedToTypedMetaObject)) return target; if (!children.Any()) return target; try { // TODO Only supports one child (lame spec) var rootType = target.Root.ComponentType; var types = children.Select(t => ConvertToType(t, rootType)).ToArray(); target = target.BindGenericParameters(types); } catch (Exception ex) { if (ex.IsCriticalException()) throw; Parent.errors.CouldNotBindGenericParameters(target.ComponentType, ex, self.FileLocation); } Parent.Bind(target, children.First(), null); children.Clear(); return target; }
private string GetItemName() { string noteName = DefaultItemName; if (NodeList.Any(x => x.Name == noteName)) { return(GetItemName()); } return(noteName); }
private async Task <string> GenerateClusterManifestWithAddedNodes(List <NodeDescription> addedNodes, NodeList nodesFromFM, List <NodeTypeDescription> allNodeTypes) { string clusterManifestContent = await FabricClientRetryHelper.ExecuteFabricActionWithRetryAsync( () => this.fabricClient.ClusterManager.GetClusterManifestAsync(Constants.FabricQueryTimeoutInMinutes, this.cancellationToken), Constants.FabricQueryRetryTimeoutInMinutes, this.cancellationToken).ConfigureAwait(false); var clusterManifest = XMLHelper.ReadClusterManifestFromContent(clusterManifestContent); var infrastructureType = clusterManifest.Infrastructure.Item as ClusterManifestTypeInfrastructureWindowsServer; infrastructureType.ThrowIfNull("Node Infrastructure section is not available in the cluster manifest."); var nodesList = infrastructureType.NodeList.ToList(); var nodeTypes = clusterManifest.NodeTypes.ToList(); foreach (var node in addedNodes) { if (!nodesFromFM.Any(nodeFromFM => nodeFromFM.NodeName == node.NodeName)) { nodesList.Add(new FabricNodeType { NodeName = node.NodeName, UpgradeDomain = node.UpgradeDomain, FaultDomain = node.FaultDomain, IPAddressOrFQDN = node.IPAddress, NodeTypeRef = node.NodeTypeRef, IsSeedNode = false }); if (!nodeTypes.Any(nt => nt.Name == node.NodeTypeRef)) { nodeTypes.Add(this.GetCMNodeTypeFromNodeDescription(allNodeTypes.Single(nt => nt.Name == node.NodeTypeRef))); } } } infrastructureType.NodeList = nodesList.ToArray(); clusterManifest.NodeTypes = nodeTypes.ToArray(); string clusterManifestPath = Path.Combine(Path.GetTempPath(), "clusterManifest.xml"); XMLHelper.WriteClusterManifest(clusterManifestPath, clusterManifest); UpgradeOrchestrationTrace.TraceSource.WriteInfo(TraceType, "Cluster manifest with newly added nodes written to {0}", clusterManifestPath); return(clusterManifestPath); }
private NodeList FilterPrimaryNodeTypesStatus(NodeList nodes, List <string> primaryNodeTypes) { if (nodes == null || !nodes.Any()) { return(nodes); } if (primaryNodeTypes == null || !primaryNodeTypes.Any()) { return(nodes); } var nodeList = new NodeList(); foreach (var node in nodes) { if (primaryNodeTypes.Contains(node.NodeType)) { nodeList.Add(node); } } return(nodeList); }