예제 #1
0
        private DataString GetSubFieldData(DataDefinition elementDef, DataString elementData, int field)
        {
            if (elementDef.HasSubfields())
            {
                int readerIndex = 0;

                DataString tempData = elementData.Clone();

                foreach (KeyValuePair <int, DataDefinition> kvp in elementDef.SubDefinitions)
                {
                    if (kvp.Key != field)
                    {
                        kvp.Value.GetAllData(tempData, ref readerIndex);
                        tempData = tempData.SubString(readerIndex);
                    }
                    else
                    {
                        DataDefinition fieldDefinition = kvp.Value;
                        return(fieldDefinition.GetAllData(tempData));
                    }
                }
            }

            return(elementDef.GetAllData(elementData));
        }
예제 #2
0
        private void CreateMTI(DataString dataString)
        {
            string mti = dataString.Data.Substring(readerIndex, 4);

            readerIndex           = 4;
            MessageTypeIdentifier = new MessageTypeIdentifier(mti);;
        }
예제 #3
0
        private void CreateDEs(DataString dataString)
        {
            DataElements = new DataElementCollection();

            DataString dataElementsString = dataString.SubString(readerIndex);

            List <int> dataElementsBitMap = BitMaps.GetPresentDataElements();

            foreach (int de in dataElementsBitMap)
            {
                if (DataDefinitionDictionary.ContainsElementDefinition(de))
                {
                    DataDefinition dataDef = DataDefinitionDictionary.GetDataDefinition(de);

                    int dataElementsReaderIndex = 0;

                    try
                    {
                        DataString data = dataDef.GetAllData(dataElementsString, ref dataElementsReaderIndex);

                        dataElementsString = dataElementsString.SubString(dataElementsReaderIndex);

                        DataElements.AddOrReplaceDataElement(new DataElement(de, dataDef, data));
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Missing or incorrectly defined DE: " + de + ".", ex);
                    }
                }
                else
                {
                    throw new Exception("Missing definition, DE: " + de + ".");
                }
            }
        }
        public override string GetFieldData(DataString data)
        {
            int lengthType  = (int)LenthType;
            int fieldLength = int.Parse(data.SubString(0, lengthType).ToString());

            return(data.SubString(lengthType, fieldLength).ToString());
        }
예제 #5
0
        private bool IsValidString(DataString dataString)
        {
            if (dataString.Length < 20)
            {
                return(false);
            }

            return(true);
        }
        public override DataString GetSubFieldData(DataString elementData, int field)
        {
            if (HasSubfields())
            {
                DataString fieldsData = elementData.SubString((int)LenthType);

                return(base.GetSubFieldData(fieldsData, field));
            }

            throw new ArgumentException(nameof(GetSubFieldData));
        }
        public override DataString GetAllData(DataString data, ref int nextFieldIndex)
        {
            int lengthType = (int)LenthType;

            int fieldLength = int.Parse(data.SubString(0, lengthType).ToString());

            if (fieldLength > _maxLength)
            {
                throw new ArgumentOutOfRangeException(nameof(VariableLenthType));
            }

            nextFieldIndex = lengthType + fieldLength;

            return(data.SubString(0, nextFieldIndex));
        }
예제 #8
0
        public Message(DataString dataString, DataElementsDefinition dataElementDefinition)
        {
            DataDefinitionDictionary = dataElementDefinition
                                       ?? throw new ArgumentNullException(nameof(DataElementsDefinition));

            if (IsValidString(dataString))
            {
                CreateMTI(dataString);
                CreateBitMaps(dataString);
                CreateDEs(dataString);
            }
            else
            {
                throw new ArgumentException(nameof(DataString));
            }
        }
        public DataElement(int number, DataDefinition dataDefinition, DataString data)
        {
            SubElements = new DataElementCollection();
            Number      = number;
            Definition  = dataDefinition;

            if (dataDefinition.HasSubfields())
            {
                foreach (KeyValuePair <int, DataDefinition> kvp in dataDefinition.SubDefinitions)
                {
                    int            fieldNumber     = kvp.Key;
                    DataDefinition fieldDefinition = kvp.Value;
                    DataString     fieldData       = dataDefinition.GetSubFieldData(data, fieldNumber);
                    SubElements.AddOrReplaceDataElement(new DataElement(fieldNumber, fieldDefinition, fieldData));
                }
            }
            else
            {
                _data = data;
            }
        }
예제 #10
0
        private void CreateBitMaps(DataString dataString)
        {
            DataString bitMapString = dataString.SubString(readerIndex, 16);

            readerIndex = readerIndex + 16;

            BitMaps = new BitMapCollection(bitMapString);

            while (bitMapString.ToBibnaryString()[0] == '1')
            {
                if (dataString.Length < readerIndex + 16)
                {
                    throw new ArgumentException(nameof(DataString));
                }

                bitMapString = dataString.SubString(readerIndex, 16);

                readerIndex = readerIndex + 16;

                BitMaps.AddBitMap(bitMapString);
            }
        }
예제 #11
0
 public abstract DataString GetAllData(DataString data, ref int nextFieldIndex);
예제 #12
0
        public DataString GetAllData(DataString data)
        {
            int nextFieldIndex = 0;

            return(GetAllData(data, ref nextFieldIndex));
        }
예제 #13
0
 public DataString ToISOString()
 {
     return(DataString.FromBinaryString(ToBinaryString()));
 }
 public override string GetFieldData(DataString data)
 {
     return(GetAllData(data).ToString());
 }
 public override DataString GetAllData(DataString data, ref int nextFieldIndex)
 {
     nextFieldIndex = Length;
     return(data.SubString(0, Length));
 }
예제 #16
0
 public void AddBitMap(DataString stringBitMap)
 {
     AddBitMap(stringBitMap.ToBibnaryString());
 }
예제 #17
0
 public BitMapCollection(DataString firstBitmapString)
 {
     AddBitMap(firstBitmapString);
 }
예제 #18
0
 public virtual DataString GetSubFieldData(DataString elementData, int field)
 {
     return(GetSubFieldData(this, elementData, field));
 }
예제 #19
0
 public abstract string GetFieldData(DataString data);