/// <summary> /// 把架构导出成文本 /// </summary> /// <returns></returns> public string ExportToXml() { Iso8583Field[] array = new Iso8583Field[this.fields.Count]; int i = 0; foreach (KeyValuePair <int, Iso8583Field> kvp in this.fields) { array[i++] = kvp.Value; } XmlSerializer serial = new XmlSerializer(typeof(Iso8583Field[])); StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); serial.Serialize(writer, array); return(sb.ToString()); }
/// <summary> /// 增加一个数据域 /// </summary> /// <param name="field">数据域信息</param> public void AddField(Iso8583Field field) { if (field == null) { throw new ArgumentNullException("field"); } if (this.fields.ContainsKey(field.BitNum)) { throw new Exception("数据域字义已经存在。"); } if (field.BitNum < 0 || field.BitNum > Bitmap.FieldCount) { //if (field.BitNum < 1 || field.BitNum > Bitmap.FieldCount) throw new Exception("位域值不合法。"); } this.fields.Add(field.BitNum, field); this.bitmap.Set(field.BitNum, true); }