Exemplo n.º 1
0
        // ------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="HeaderSignature"/> class.
        /// </summary>
        /// <param name="checker">The checker.</param>
        /// <param name="signatureName">Name of the signature.</param>
        /// <param name="fileExtensions">The file extensions.</param>
        /// <param name="prohibitionMode">The prohibition mode.</param>
        public HeaderSignature(
            ISignatureChecker checker,
            string signatureName,
            string[] fileExtensions,
            ProhibitionMode prohibitionMode)
        {
            _checker         = checker;
            _signatureName   = signatureName;
            _fileExtensions  = fileExtensions;
            _prohibitionMode = prohibitionMode;
            _byteoffset      = 0;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderSignature"/> class.
 /// </summary>
 /// <param name="hexStringSignature">The hex string signature.</param>
 /// <param name="signatureName">Name of the signature.</param>
 /// <param name="fileExtensions">The file extensions.</param>
 /// <param name="prohibitionMode">The prohibition mode.</param>
 public HeaderSignature(
     string hexStringSignature,
     string signatureName,
     string[] fileExtensions,
     ProhibitionMode prohibitionMode)
     :
     this(
         hexStringSignature,
         signatureName,
         fileExtensions,
         prohibitionMode,
         SignatureMode.HexString)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderSignature"/> class.
 /// </summary>
 /// <param name="hexStringSignature">The hex string signature.</param>
 /// <param name="signatureName">Name of the signature.</param>
 /// <param name="fileExtensions">The file extensions.</param>
 /// <param name="prohibitionMode">The prohibition mode.</param>
 /// <param name="signatureMode">The signature mode.</param>
 public HeaderSignature(
     string hexStringSignature,
     string signatureName,
     string[] fileExtensions,
     ProhibitionMode prohibitionMode,
     SignatureMode signatureMode)
 {
     _checker = new SimplePatternSignatureChecker(0, 0,
                                                  hexStringSignature,
                                                  signatureMode);
     _signatureName   = signatureName;
     _fileExtensions  = fileExtensions;
     _prohibitionMode = prohibitionMode;
     _byteoffset      = 0;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderSignature"/> class.
 /// </summary>
 /// <param name="hexStringSignature">The hex string signature.</param>
 /// <param name="signatureName">Name of the signature.</param>
 /// <param name="fileExtensions">The file extensions.</param>
 /// <param name="prohibitionMode">The prohibition mode.</param>
 public HeaderSignature(
     int byteoffset,
     int firstnumberofbytestoread,
     string hexStringSignature,
     string signatureName,
     string[] fileExtensions,
     ProhibitionMode prohibitionMode)
     :
     this(
         byteoffset,
         firstnumberofbytestoread,
         hexStringSignature,
         signatureName,
         fileExtensions,
         prohibitionMode,
         SignatureMode.HexString)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HeaderSignature"/> class.
 /// </summary>
 /// <param name="hexStringSignature">The hex string signature.</param>
 /// <param name="signatureName">Name of the signature.</param>
 /// <param name="fileExtensions">The file extensions.</param>
 /// <param name="prohibitionMode">The prohibition mode.</param>
 /// <param name="signatureMode">The signature mode.</param>
 public HeaderSignature(
     int byteoffset,
     int firstnumberofbytestoread,
     string hexStringSignature,
     string signatureName,
     string[] fileExtensions,
     ProhibitionMode prohibitionMode,
     SignatureMode signatureMode)
 {
     _checker = new SimplePatternSignatureChecker(
         byteoffset,
         firstnumberofbytestoread,
         hexStringSignature,
         signatureMode);
     _signatureName   = signatureName;
     _fileExtensions  = fileExtensions;
     _prohibitionMode = prohibitionMode;
     _byteoffset      = byteoffset;
 }
Exemplo n.º 6
0
        // ------------------------------------------------------------------
        #endregion

        #region Public methods.
        // ------------------------------------------------------------------

        public static HeaderSignature[] CustomSignatures(DataTable dtSignatures)
        {
            List <HeaderSignature> hds = new List <HeaderSignature>();
            string          strHexPattern;
            string          strSignatureName;
            int             intByteOffset = 0;
            int             intFirstNumberOfBytesToRead = 0;
            string          strFileExtensions;
            bool            blEnabled    = false;
            bool            blProhibited = false;
            ProhibitionMode pmode        = ProhibitionMode.Allowed;

            char[] delimiters = new char[] { ';' };

            foreach (DataRow row in dtSignatures.Rows)
            {
                blEnabled = FixNullbool(row["Enabled"]);
                int.TryParse(FixNullstring(row["ByteOffset"]), out intByteOffset);
                int.TryParse(FixNullstring(row["FirstNumberOfBytesToRead"]), out intFirstNumberOfBytesToRead);
                strHexPattern     = FixNullstring(row["HexPattern"]);
                strSignatureName  = FixNullstring(row["SignatureName"]);
                strFileExtensions = FixNullstring(row["FileExtensions"]);

                string[] strArr_FileExtensions = strFileExtensions.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                blProhibited = FixNullbool(row["Prohibited"]);
                if (blProhibited)
                {
                    pmode = ProhibitionMode.Prohibited;
                }
                else
                {
                    pmode = ProhibitionMode.Allowed;
                }
                if (blEnabled)
                {
                    hds.Add(new HeaderSignature(intByteOffset, intFirstNumberOfBytesToRead, strHexPattern, strSignatureName, strArr_FileExtensions, pmode));
                }
            }
            return(hds.ToArray());
        }