Beispiel #1
0
        Encoding iso8859; // to chache encoding (getencoding is pretty expensive)

        public DataField(string tag, DataDescriptiveField fieldDescription, byte[] bytes) : base(tag)
        {
            _fieldDescription = fieldDescription;
            _bytes            = bytes;
            iso8859           = Encoding.GetEncoding("iso-8859-1");

            int currentIndex = 0;
            int start        = 0;
            int tagCount     = _fieldDescription.SubFieldDefinitions.Count;

            if (tagCount > 0)
            {
                string[] tags = new string[tagCount];
                for (int i = 0; i < tagCount; i++)
                {
                    tags[i] = _fieldDescription.SubFieldDefinitions[i].Tag;
                }
                subFields = new SubFields(tags);
                //while (bytes[currentIndex] != FieldTerminator && currentIndex < Bytes.Length) //need to ignore fieldterminator as it can be part of a valid coordiante in sg2d field
                while (currentIndex < Bytes.Length - 1)
                {
                    subFieldRow = new object[tagCount];
                    parseSubfields(ref tag, ref _fieldDescription, ref start, ref currentIndex, ref _bytes);
                    subFields.Values.Add(subFieldRow);
                }
            }
        }
Beispiel #2
0
        public DataField(string tag, DataDescriptiveField fieldDescription, ArraySegment <byte> bytes) : base(tag)
        {
            _fieldDescription = fieldDescription;

            int currentIndex = 0;
            int start        = 0;
            int tagCount     = _fieldDescription.SubFieldDefinitions.Count;

            if (tagCount > 0)
            {
                List <string> tags = new List <string>(tagCount);
                for (int i = 0; i < tagCount; i++)
                {
                    tags.Add(_fieldDescription.SubFieldDefinitions[i].Tag);
                }
                subFields = new SubFields(tags);
                //while (bytes[currentIndex] != FieldTerminator && currentIndex < Bytes.Length) //need to ignore fieldterminator as it can be part of a valid coordiante in sg2d field
                while (currentIndex < bytes.Count - 1)
                {
                    subFieldRow = new SFcontainer[tagCount];
                    parseSubfields(ref tag, ref _fieldDescription, ref start, ref currentIndex, ref bytes);
                    subFields.Values.Add(subFieldRow);
                }
            }
        }
Beispiel #3
0
 public static byte[] GetBytes(this SubFields val, int row, string Tag)
 {
     return((byte[])(val.Values[row][val.TagIndex[Tag]]));
 }
Beispiel #4
0
 public static Double GetDouble(this SubFields val, int row, string Tag)
 {
     return(Convert.ToDouble(val.Values[row][val.TagIndex[Tag]]));
 }
Beispiel #5
0
 public static String GetString(this SubFields val, int row, string Tag)
 {
     return((String)(val.Values[row][val.TagIndex[Tag]]));
 }
Beispiel #6
0
 public static UInt32 GetUInt32(this SubFields val, int row, string Tag)
 {
     return((UInt32)(val.Values[row][val.TagIndex[Tag]]));
 }
Beispiel #7
0
 public static byte[] GetBytes(this SubFields val, int row, string Tag)
 {
     return((byte[])val.Values[row][val.TagIndex.IndexOf(Tag)].otherValue);
 }
Beispiel #8
0
 public static Double GetDouble(this SubFields val, int row, string Tag)
 {
     return(Convert.ToDouble(val.Values[row][val.TagIndex.IndexOf(Tag)].otherValue));
 }
Beispiel #9
0
 public static String GetString(this SubFields val, int row, string Tag)
 {
     return((String)val.Values[row][val.TagIndex.IndexOf(Tag)].otherValue);
 }
Beispiel #10
0
 public static UInt32 GetUInt32(this SubFields val, int row, string Tag)
 {
     return(val.Values[row][val.TagIndex.IndexOf(Tag)].uintValue);
 }