Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CrcHashAlgorithm{TTable}"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        public CrcHashAlgorithm(CRCTypes type)
        {
            FieldInfo            fi = type.GetType().GetField(type.ToString());
            DescriptionAttribute m  = fi.GetCustomAttributes(typeof(DescriptionAttribute), false).Single() as DescriptionAttribute;

            if (m == null)
            {
                throw new ArgumentNullException("Not exist description attribute.");
            }

            CrcName = m.Description;

            if (!Paramters.ContainsKey(CrcName))
            {
                throw new ArgumentException();
            }

            Paramter = Paramters[CrcName];
            CrcType  = type;
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CRC32"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public CRC32(CRCTypes type) : base(type)
 {
     Mask = uint.MaxValue >> (byte)(16 - Paramter.Width);
     Initialize();
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CRC8"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public CRC8(CRCTypes type) : base(type)
 {
     Mask = (byte)(byte.MaxValue >> (byte)(16 - Paramter.Width));
     Initialize();
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CRC16"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public CRC16(CRCTypes type) : base(type)
 {
     Mask = (ushort)(ushort.MaxValue >> (byte)(16 - Paramter.Width));
     Initialize();
 }