本文整理汇总了C#中Castle.Components.Binder.CompositeNode.AddChildNode方法的典型用法代码示例。如果您正苦于以下问题:C# CompositeNode.AddChildNode方法的具体用法?C# CompositeNode.AddChildNode怎么用?C# CompositeNode.AddChildNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.Components.Binder.CompositeNode
的用法示例。
在下文中一共展示了CompositeNode.AddChildNode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessElement
public Node ProcessElement(XElement startEl)
{
if (IsComplex(startEl))
{
CompositeNode top = new CompositeNode(startEl.Name.LocalName);
foreach (var attr in startEl.Attributes())
{
var leaf = new LeafNode(typeof(String), attr.Name.LocalName, attr.Value);
top.AddChildNode(leaf);
}
foreach (var childEl in startEl.Elements())
{
var childNode = ProcessElement(childEl);
top.AddChildNode(childNode);
}
return top;
}
else
{
LeafNode top = new LeafNode(typeof(String), "", "");
return top;
}
}
示例2: PopulateTree
/// <summary>
///
/// </summary>
/// <param name="root"></param>
/// <param name="reader"></param>
/// <param name="prefix"></param>
public void PopulateTree(CompositeNode root, IDataReader reader, String prefix)
{
string[] fields = GetFields(reader);
int[] indexesToSkip = FindDuplicateFields(fields);
IndexedNode indexNode = new IndexedNode(prefix);
int row = 0;
while(reader.Read())
{
CompositeNode node = new CompositeNode(row.ToString());
for(int i=0; i<reader.FieldCount; i++)
{
// Is in the skip list?
if (Array.IndexOf(indexesToSkip, i) >= 0) continue;
// Is null?
if (reader.IsDBNull(i)) continue;
Type fieldType = reader.GetFieldType(i);
node.AddChildNode(new LeafNode(fieldType, fields[i], reader.GetValue(i)));
}
indexNode.AddChildNode(node);
row++;
}
root.AddChildNode(indexNode);
}
示例3: BuildNode
public CompositeNode BuildNode(XDocument doc)
{
var rootNode = new CompositeNode("root");
rootNode.AddChildNode(ProcessElement(doc.Root));
return rootNode;
}
示例4: GetParamsNode
private static CompositeNode GetParamsNode(int expectedValue)
{
CompositeNode paramsNode = new CompositeNode("root");
IndexedNode listNode = new IndexedNode("myList");
paramsNode.AddChildNode(listNode);
listNode.AddChildNode(new LeafNode(typeof(int), "", expectedValue));
return paramsNode;
}
示例5: GetOrCreateIndexedNode
private IndexedNode GetOrCreateIndexedNode(CompositeNode parent, string nodeName)
{
Node node = parent.GetChildNode(nodeName);
if (node != null && node.NodeType != NodeType.Indexed)
{
throw new BindingException("Attempt to create or obtain an indexed node " +
"named {0}, but a node with the same exists with the type {1}", nodeName, node.NodeType);
}
if (node == null)
{
node = new IndexedNode(nodeName);
parent.AddChildNode(node);
}
return (IndexedNode) node;
}
示例6: AddLeafNode
private void AddLeafNode(CompositeNode parent, Type type, String nodeName, object value)
{
parent.AddChildNode(new LeafNode(type, nodeName, value));
}
示例7: AddToRoot
public void AddToRoot(CompositeNode rootNode, XDocument doc)
{
var top = ProcessElement(doc.Root);
rootNode.AddChildNode(top);
}