本文整理汇总了C#中Protocol.createBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Protocol.createBlock方法的具体用法?C# Protocol.createBlock怎么用?C# Protocol.createBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol.createBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createProtocol
public static void createProtocol(TreeView tree)
{
TreeNodeCollection treeCol = tree.Nodes;
Protocol prot = new Protocol(treeCol[0].Text, treeCol[0].ImageKey, treeCol[0].SelectedImageKey);
Block data = null;
foreach (TreeNode t in treeCol[0].Nodes)
{
if (t.Name.Equals("block"))
{
data = prot.createBlock(t.Text, t.ImageKey, t.SelectedImageKey);
createProtocol(t.Nodes, data);
}
else
{
if(t.Name.Equals("multi"))
{
Field f = prot.createField(t.Text, t.Name, "", t.SelectedImageKey);
string[] values = t.ImageKey.Split(';');
foreach(string s in values)
{
string[] pair = s.Split(':');
((MultiField)f).addKey(pair[0], pair[1]);
}
} else prot.createField(t.Text, t.Name, t.ImageKey, t.SelectedImageKey);
}
}
createXML(prot);
}
示例2: parse
public Protocol parse(String path)
{
// parse protocol attributes
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
Protocol protocol = null;
XmlNodeList protocolNode = xmlDoc.DocumentElement.SelectNodes("/protocol");
// parsing protocol attributes
if (protocolNode != null)
{
string protoName = null, protoSource = null, protoDescription = null;
foreach (XmlNode node in protocolNode)
{
if (node.Attributes["name"] != null)
{
protoName = node.Attributes["name"].Value;
}
if (node.Attributes["source"] != null)
{
protoSource = node.Attributes["source"].Value;
}
if (node.Attributes["description"] != null)
{
protoDescription = node.Attributes["description"].Value;
}
}
//creating new protocol instance
protocol = new Protocol(protoName, protoSource, protoDescription);
//getting all the blo
XmlNodeList nodes = xmlDoc.DocumentElement.SelectNodes("/protocol/block|/protocol/field");
//going over all the nodes and creating their instances
foreach (XmlNode node in nodes)
{
if (node.Name == "block")
{
String[] attr = getBlockAttr(node);
String name = attr[0];
String type = attr[1];
String info = attr[2];
Block block = protocol.createBlock(name, type, info);
innerBlocks(block, node.ChildNodes);
}
else if (node.Name == "field")
{
String[] attr = getFieldAttr(node);
String name = attr[0];
String type = attr[1];
String info = attr[2];
String description = attr[3];
Field field = protocol.createField(name, type, info, description);
if (node.ChildNodes != null)
{
innerFields(field, node.ChildNodes);
}
}
}
}
return protocol;
}