扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
来源:天极开发 2007年10月13日
关键字:
图5.示例2的增加硬件到方法/模板图,我添加了描述每个结点的硬件的标签。我把一个客户添加到示例"Mary Machine"来说明还有一个"pc client"模板。 |
public static void Main(string[] args){ Hashtable mainHash; IDictionaryEnumerator ienum; Node tNode; string name = ReadString("Please enter the XMI filename : "); NodeParse np = new NodeParse(name); mainHash = np.getNodes(); ienum = mainHash.GetEnumerator(); while (ienum.MoveNext()) { tNode = (Node)ienum.Value; System.Console.WriteLine("Node ="+tNode.name+" CPU= "+tNode.CPU); } System.Console.ReadLine(); } |
using System; using System.Text; namespace XMI_1 { class Node{ string _name,_id = "",_CPU,_MemorySize,_DiskSize,_Note,_Purpose, _Stereotype,Vendor; public Node(string p_id) {this._name = p_id;} public string id {get { return _id;} public string name{get {return _name;} set {_name = value;}} public string CPU {get { return _CPU;} set {_CPU = value;}} public string MemorySize{get {return _MemorySize;} set {_MemorySize = value;}} public string DiskSize {get {return _DiskSize;}set {_DiskSize = value;}} public string Notes{get {return _Notes;}set {_Notes = value;}} public string Purpose{get {return _Purpose;} set {_Purpose = value;}} public string Stereotype {get {return _Stereotype;} set {_Stereotype = value;}} public string Vendor {get {return _Vendor;} set {_Vendor = value;}} } } |
图6.Trucks与Persons结点实例都继承自Fleet Management结点。 |
public static void Main(string[] args) { Hashtable mainHash; IDictionaryEnumerator ienum; Node tNode; string name = ReadString("Please enter the XMI filename : "); NodeParse np = new NodeParse(name); mainHash = np.getNodes(); ienum = mainHash.GetEnumerator(); while (ienum.MoveNext()){ tNode = (Node)ienum.Value; System.Console.WriteLine("Node = " + tNode.name); //Add "if (tNode. != null)" for each Writeline() System.Console.WriteLine(" CPU = " + tNode.CPU); System.Console.WriteLine(" DiskSize = " + tNode.DiskSize); System.Console.WriteLine(" MemorySize = " + tNode.MemorySize); System.Console.WriteLine(" Purpose = " + tNode.Purpose); System.Console.WriteLine(" Notes = " + tNode.Notes); System.Console.WriteLine("Node refers to = " + tNode.classname); System.Console.WriteLine("Node addr is " + tNode.classifier); System.Console.WriteLine(); } System.Console.ReadLine(); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。