public void Construct_NullValue_Throws()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         VisibleString _ = null;
     });
 }
 public void Construct_WhiteSpaceCombinations_Throws(string value)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         VisibleString _ = value;
     });
 }
        public void AccessValue_DefaultConstructed_ThrowsOnAccess()
        {
            var arr = new VisibleString[1];

            Assert.Throws <InvalidOperationException>(() =>
            {
                string _ = arr[0];
            });
        }
Esempio n. 4
0
        public Apdu(TLV tlv)
            : this()
        {
            base.Identifier = BerIdentifier.Encode(BerIdentifier.Application, BerIdentifier.Constructed, 1);
            base.Bytes      = tlv.Bytes;
            ByteArraySegment pdu = tlv.Value.Bytes;

            pdu.Length = 0;
            TLV tmp = new TLV(pdu.EncapsulatedBytes());

            gocbRef = new VisibleString(tmp);

            pdu.Length       += tmp.Bytes.Length;
            tmp               = new TLV(pdu.EncapsulatedBytes());
            timeAllowedtoLive = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            datSet      = new VisibleString(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            if (IsGoIDTag(tmp.Tag.RawBytes))
            {
                goID = new VisibleString(tmp);
            }

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            t           = new UtcTime(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            stNum       = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            sqNum       = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            test        = new TAsn1.Boolean(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            confRev     = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            ndsCom      = new TAsn1.Boolean(tmp);

            pdu.Length      += tmp.Bytes.Length;
            tmp              = new TLV(pdu.EncapsulatedBytes());
            numDatSetEntries = new Integer(tmp);

            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());
            int cnt = 0;
            //    int len = tmp.Value.Bytes.Length;

            TLV data = new TLV(tmp.Value.Bytes);

            allData.Add(new Data(data));
            cnt++;

            while (cnt < numDatSetEntries.Value)
            {
                data = new TLV(tmp.Value.Bytes.EncapsulatedBytes());
                tmp.Value.Bytes.Length += data.Bytes.Length;
                //TLV data = new TLV(tmp.Value.Bytes);
                allData.Add(new Data(data));
                cnt++;
                //tmp.Value.Bytes.Length += data.Bytes.Length;
            }
        }
Esempio n. 5
0
        private void _parse()
        {
            _datatype = ((DataType)m_io.ReadU1());
            switch (Datatype)
            {
            case DataType.Integer:
            {
                _dataValue = new Integer(m_io, this, m_root);
                break;
            }

            case DataType.Unsigned:
            {
                _dataValue = new Unsigned(m_io, this, m_root);
                break;
            }

            case DataType.Long:
            {
                _dataValue = new Long(m_io, this, m_root);
                break;
            }

            case DataType.Boolean:
            {
                _dataValue = new Boolean(m_io, this, m_root);
                break;
            }

            case DataType.Structure:
            {
                _dataValue = new Structure(m_io, this, m_root);
                break;
            }

            case DataType.Array:
            {
                _dataValue = new Array(m_io, this, m_root);
                break;
            }

            case DataType.Float64:
            {
                _dataValue = new Float64(m_io, this, m_root);
                break;
            }

            case DataType.DoNotCare:
            {
                _dataValue = new DoNotCare(m_io, this, m_root);
                break;
            }

            case DataType.LongUnsigned:
            {
                _dataValue = new LongUnsigned(m_io, this, m_root);
                break;
            }

            case DataType.Time:
            {
                _dataValue = new Time(m_io, this, m_root);
                break;
            }

            case DataType.OctetString:
            {
                _dataValue = new OctetString(m_io, this, m_root);
                break;
            }

            case DataType.NullData:
            {
                _dataValue = new NullData(m_io, this, m_root);
                break;
            }

            case DataType.CompactArray:
            {
                _dataValue = new CompactArray(m_io, this, m_root);
                break;
            }

            case DataType.DateTime:
            {
                _dataValue = new DateTime(m_io, this, m_root);
                break;
            }

            case DataType.DoubleLongUnsigned:
            {
                _dataValue = new DoubleLongUnsigned(m_io, this, m_root);
                break;
            }

            case DataType.Float32:
            {
                _dataValue = new Float32(m_io, this, m_root);
                break;
            }

            case DataType.Long64Unsigned:
            {
                _dataValue = new Long64Unsigned(m_io, this, m_root);
                break;
            }

            case DataType.DoubleLong:
            {
                _dataValue = new DoubleLong(m_io, this, m_root);
                break;
            }

            case DataType.Long64:
            {
                _dataValue = new Long64(m_io, this, m_root);
                break;
            }

            case DataType.Date:
            {
                _dataValue = new Date(m_io, this, m_root);
                break;
            }

            case DataType.Enum:
            {
                _dataValue = new Enum(m_io, this, m_root);
                break;
            }

            case DataType.Bcd:
            {
                _dataValue = new Bcd(m_io, this, m_root);
                break;
            }

            case DataType.VisibleString:
            {
                _dataValue = new VisibleString(m_io, this, m_root);
                break;
            }

            case DataType.BitString:
            {
                _dataValue = new BitString(m_io, this, m_root);
                break;
            }
            }
        }
Esempio n. 6
0
        public Asdu(TLV tlv)
            : this()
        {
            Bytes = tlv.Bytes;
            ByteArraySegment pdu = tlv.Value.Bytes;

            pdu.Length = 0;
            TLV tmp = new TLV(pdu.EncapsulatedBytes());

            svID        = new VisibleString(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            if (IsDatset(tmp))
            {
                datset      = new VisibleString(tmp);
                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }

            smpCnt      = new Integer(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            confRev     = new Integer(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            if (IsRefrTm(tmp))
            {
                refrTm      = new UtcTime(tmp);
                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }

            smpSynch    = new TAsn1.Boolean(tmp);
            pdu.Length += tmp.Bytes.Length;
            tmp         = new TLV(pdu.EncapsulatedBytes());

            if (!smpSynch.Value)
            {
                smpRate     = new TAsn1.Boolean(tmp);
                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }


            tmp = new TLV(pdu.EncapsulatedBytes());

            ByteArraySegment chn = tmp.Value.Bytes;

            chn.Length = Channel.ChannelLength;
            sample.Add(new Channel(chn));
            // Confirm the loop
            while (chn.Length + chn.Offset < chn.BytesLength)
            {
                chn        = chn.EncapsulatedBytes();
                chn.Length = Channel.ChannelLength;
                sample.Add(new Channel(chn));
            }
        }