コード例 #1
0
        /// <summary>
        /// Validates this instance.
        /// </summary>
        /// <remarks>
        /// <para>Ensures that <see cref="MerchantId"/>, <see cref="DeviceId"/>, <see cref="PosVersion"/> and <see cref="OperatorId"/> are not null, empty string or only whitespace.
        /// Also ensure no property is larger than it's maximum allowed length (see individual property notes for details).
        /// </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">Thrown if <see cref="MerchantId"/>, <see cref="DeviceId"/>, <see cref="PosVersion"/>, or <see cref="OperatorId"/> is null.</exception>
        /// <exception cref="ArgumentException">Thrown if <see cref="MerchantId"/>, <see cref="DeviceId"/>, <see cref="PosVersion"/>, or <see cref="OperatorId"/> is empty or only whitespace, or longer than their maximum allowed lengths.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <see cref="TrackingData"/> contains more than 1000000 items.</exception>
        public virtual void Validate()
        {
            MerchantId.GuardNullOrWhiteSpace("request", nameof(MerchantId));
            MerchantId.GuardLength("request", nameof(MerchantId), 10);

            DeviceId.GuardNullOrWhiteSpace("request", nameof(DeviceId));
            DeviceId.GuardLength("request", nameof(DeviceId), 64);

            PosVersion.GuardNullOrWhiteSpace("request", nameof(PosVersion));
            PosVersion.GuardLength("request", nameof(PosVersion), 64);

            OperatorId.GuardNullOrWhiteSpace("request", nameof(OperatorId));
            OperatorId.GuardLength("request", nameof(OperatorId), 64);

            var td = this.TrackingData;

            if (td != null)
            {
                td.Count.GuardRange(nameof(TrackingData), 0, 1000000);
            }
        }