public override uint Deserialize(byte[] buffer)
{
BufferReader bufferReader = new BufferReader(buffer);
this.RestrictType = (RestrictionType)bufferReader.ReadByte();
this.restrictCount = (this.CountType == CountByte.TwoBytesCount) ? bufferReader.ReadUInt16() : bufferReader.ReadUInt32();
int count = (this.CountType == CountByte.TwoBytesCount) ? (int)(ushort)this.RestrictCount : (int)(uint)this.RestrictCount;
this.Restricts = new IRestriction[count];
uint size = bufferReader.Position;
byte[] tmpArray = bufferReader.ReadToEnd();
for (int i = 0; i < count; i++)
{
RestrictionType restrictionType = (RestrictionType)tmpArray[0];
switch (restrictionType)
{
case RestrictionType.AndRestriction:
this.Restricts[i] = new AndRestriction(this.CountType);
break;
case RestrictionType.BitMaskRestriction:
this.Restricts[i] = new BitMaskRestriction();
break;
case RestrictionType.CommentRestriction:
this.Restricts[i] = new CommentRestriction(this.CountType);
break;
case RestrictionType.ComparePropertiesRestriction:
this.Restricts[i] = new ComparePropertiesRestriction();
break;
case RestrictionType.ContentRestriction:
this.Restricts[i] = new ContentRestriction();
break;
case RestrictionType.CountRestriction:
this.Restricts[i] = new CountRestriction(this.CountType);
break;
case RestrictionType.ExistRestriction:
this.Restricts[i] = new ExistRestriction();
break;
case RestrictionType.NotRestriction:
this.Restricts[i] = new NotRestriction(this.CountType);
break;
case RestrictionType.OrRestriction:
this.Restricts[i] = new OrRestriction(this.CountType);
break;
case RestrictionType.PropertyRestriction:
this.Restricts[i] = new PropertyRestriction();
break;
case RestrictionType.SizeRestriction:
this.Restricts[i] = new SizeRestriction();
break;
case RestrictionType.SubObjectRestriction:
this.Restricts[i] = new SubObjectRestriction(this.CountType);
break;
}
uint tmpLength = this.Restricts[i].Deserialize(tmpArray);
size += tmpLength;
bufferReader = new BufferReader(tmpArray);
tmpArray = bufferReader.ReadBytes(tmpLength, (uint)(tmpArray.Length - tmpLength));
}
return size;
}
}