Deserialize the common restricts type.
Example #1
0
        /// <summary>
        /// Deserialize the AndRestriction data.
        /// </summary>
        /// <param name="restrictionData">The restriction data.</param>
        public override void Deserialize(byte[] restrictionData)
        {
            int index = 0;

            this.RestrictType = (RestrictType)restrictionData[index];

            if (this.RestrictType != RestrictType.AndRestriction)
            {
                throw new ArgumentException("The restrict type is not AndRestriction type.");
            }

            index++;

            this.RestrictCount = BitConverter.ToInt16(restrictionData, index);
            index += 2;

            int count = 0;

            this.Restricts = new List <Restriction>();
            while (count < this.RestrictCount)
            {
                byte[] subData = new byte[restrictionData.Length - index];
                Array.Copy(restrictionData, index, subData, 0, subData.Length);
                Restriction restrictsTemp = RestrictsFactory.Deserialize(subData);
                this.Restricts.Add(restrictsTemp);
                count++;
            }
        }
Example #2
0
        /// <summary>
        /// Deserialize the NotRestriction data.
        /// </summary>
        /// <param name="restrictionData">The restriction data.</param>
        public override void Deserialize(byte[] restrictionData)
        {
            int index = 0;

            this.RestrictType = (RestrictType)restrictionData[index];

            if (this.RestrictType != RestrictType.NotRestriction)
            {
                throw new ArgumentException("The restrict type is not NotRestriction type.");
            }

            index++;

            byte[] subData = new byte[restrictionData.Length - index];
            Array.Copy(restrictionData, index, subData, 0, subData.Length);
            Restriction restrictsTemp = RestrictsFactory.Deserialize(subData);

            this.Restricts = restrictsTemp;
        }