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());
        }
        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));
        }
예제 #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 + ".");
                }
            }
        }
예제 #4
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));
        }
        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));
        }
예제 #6
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);
            }
        }
 public override DataString GetAllData(DataString data, ref int nextFieldIndex)
 {
     nextFieldIndex = Length;
     return(data.SubString(0, Length));
 }