Пример #1
0
 public PduSctsSegment(IPduProfileSettings settings)
 {
     if (settings == null)
     {
         throw new ArgumentNullException("Profile settings not specified.");
     }
 }
Пример #2
0
        public PduScaSegment(IPduProfileSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (settings.ServiceCenterAddress != null)
            {
                if (settings.ServiceCenterAddress.AddressType < 0 || settings.ServiceCenterAddress.AddressType > 255)
                {
                    throw new ArgumentException("Address type out of range.");
                }

                if (settings.ServiceCenterAddress.AddressValue < 0)
                {
                    throw new ArgumentException("Address value out of range.");
                }

                _type                     = settings.ServiceCenterAddress.AddressType.ToString("X2");
                _addressValue             = settings.ServiceCenterAddress.AddressValue;
                _address                  = settings.ServiceCenterAddress.AddressValue.ToBdcString();
                _length                   = _address.OctetsCount() + 1;
                HasInternationalNumbering = settings.ServiceCenterAddress.AddressType == Constants.InternationalAddressType;
            }
        }
Пример #3
0
 public IPduProfile CreateDefaultProfile(IPduProfileSettings settings, string name)
 {
     return(new PduDefaultProfile(settings)
     {
         Name = name
     });
 }
Пример #4
0
        private IPduProfileSettings loadProfileSettings(Stream jsonFile, Type profileType)
        {
            IPduProfileSettings result = null;

            try
            {
                var reader = new StreamReader(jsonFile);

                var profileText  = reader.ReadToEnd();
                var profileBytes = Encoding.UTF8.GetBytes(profileText);

                using (var profileStream = new MemoryStream(profileBytes))
                {
                    var deserializer    = new DataContractJsonSerializer(profileType);
                    var profileSettings = deserializer.ReadObject(profileStream);

                    if (profileSettings is IPduProfileSettings)
                    {
                        result = profileSettings as IPduProfileSettings;
                    }
                }
            }
            catch { }

            return(result);
        }
Пример #5
0
 public PduReceiveHeaderSegment(IPduProfileSettings settings)
     : base(settings)
 {
     if (!settings.CanDeliver || GetMessageType() != MTI.Delivery)
     {
         throw new ArgumentException("Profile settings not valid.");
     }
 }
Пример #6
0
 public PduSendHeaderSegment(IPduProfileSettings settings)
     : base(settings)
 {
     if (!settings.CanSubmit || GetMessageType() != MTI.Submit)
     {
         throw new ArgumentException("Profile settings not valid.");
     }
 }
Пример #7
0
        public PduDefaultProfile(IPduProfileSettings settings)
        {
            if (settings == null || !sequenceIsValid(settings))
            {
                throw new ArgumentNullException("Profile settings not specified or not valid.");
            }

            Settings = settings;

            Reset();
        }
Пример #8
0
        public PduHeaderSegment(IPduProfileSettings settings)
        {
            if (settings == null || settings.PduHeader == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (settings.PduHeader.Value < 0 || settings.PduHeader.Value > 255)
            {
                throw new ArgumentException("Value out of range.");
            }

            _header = settings.PduHeader.Value;
        }
Пример #9
0
        private IPduProfileSettings loadDefaultProfileSettings(string name, Type profileType)
        {
            IPduProfileSettings result = null;

            using (var profileResource = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(PduProfileManager), name))
            {
                var profile = loadProfileSettings(profileResource, profileType);
                if (profile != null)
                {
                    result = profile;
                }
            }

            return(result);
        }
Пример #10
0
        public PduPidSegment(IPduProfileSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (settings.ProtocolIdentifier != null)
            {
                if (settings.ProtocolIdentifier.Value < 0 || settings.ProtocolIdentifier.Value > 255)
                {
                    throw new ArgumentException("Protocol id out of range.");
                }

                _pid = settings.ProtocolIdentifier.Value;
            }
        }
Пример #11
0
        public PduMrSegment(IPduProfileSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (settings.MessageReference != null)
            {
                if (settings.MessageReference.Value < 0 || settings.MessageReference.Value > 255)
                {
                    throw new ArgumentException("Message id out of range.");
                }

                _mr = settings.MessageReference.Value;
            }
        }
Пример #12
0
        public PduUdSegment(IPduProfileSettings settings, PduDcsSegment dcs)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (dcs == null || dcs.GetCodingScheme() == DCS.Other)
            {
                throw new NotSupportedException("Data coding scheme not supported.");
            }

            _dcs    = dcs;
            _source = settings?.UserData?.Value ?? string.Empty;

            encode(_source, dcs.GetCoder());
        }
Пример #13
0
        public PduVpSegment(IPduProfileSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (settings.ValidityPeriod != null)
            {
                if (settings.ValidityPeriod.Value < 0 || settings.ValidityPeriod.Value > 255)
                {
                    throw new ArgumentException("Validity period out of range.");
                }

                _vp = settings.ValidityPeriod.Value;
            }
        }
Пример #14
0
        public PduDcsSegment(IPduProfileSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("Profile settings not specified.");
            }

            if (settings.DataCodingScheme != null)
            {
                if (settings.DataCodingScheme.Value < 0 || settings.DataCodingScheme.Value > 255)
                {
                    throw new ArgumentException("Data coding scheme out of range.");
                }

                _dcs = settings.DataCodingScheme.Value;
            }

            createCoders();
        }
Пример #15
0
 private bool sequenceIsValid(IPduProfileSettings settings)
 {
     return((settings.CanDeliver ^ settings.CanSubmit) && new HashSet <PduSegment>(settings.Sequence).Count == settings.Sequence.Count());
 }