Exemplo n.º 1
0
    private Scanner[] Scanners;      //kolejka skanerów

    public ScanQueue(string FiletoScan, ConfigParser config, ref XMLParser raport)
    {
        _FileToScan    = FiletoScan;
        _config        = config;
        Scannersstring = config.GetArrayValue("Antivirus", "Scanners");
        Scanners       = new Scanner[Scannersstring.Length];
        for (int i = 0; i < Scannersstring.Length; i++)
        {
            var arguments = config.GetValue(Scannersstring[i], "arguments");
            arguments   = string.Format(arguments, _FileToScan);
            Scanners[i] = new Scanner(config.GetValue(Scannersstring[i], "exeLocation"), arguments, config.GetValue(Scannersstring[i], "regex"), ref raport, Scannersstring[i]);
        }

        for (int i = 0; i < Scanners.Length; i++)
        {
            var result = Scanners[i].Scan(_FileToScan, 10000);
            Console.WriteLine(result);
        }
    }
Exemplo n.º 2
0
        public void ArrayIsReadCorrectly()
        {
            // Set up
            var settings = new ConfigParserSettings {
                MultiLineValues = MultiLineValues.Simple | MultiLineValues.QuoteDelimitedValues
            };
            var configFile = new ConfigParser(
                @"[Advanced]
                Select =
                     select * from
                     from table
                     where ID = '5'
                ",
                settings);

            // Act
            var arrayValues = configFile.GetArrayValue("Advanced", "Select");

            // Assert
            Assert.Equal(3, arrayValues?.Length ?? 0);
            Assert.Equal("select * from", arrayValues[0]);
            Assert.Equal("from table", arrayValues[1]);
            Assert.Equal("where ID = '5'", arrayValues[2]);
        }
Exemplo n.º 3
0
        public void ParsingConfigFileStringWorks()
        {
            var configFileFromString = new ConfigParser(@"
                [Strings]
                    canBeIndented = value
                andQuoted = ""quotes will be stripped""

                [Numbers]
                withD = 0.6D
                dollars = $2,999

                [boolean]
                numericTrue = 1
                textFalse = true
                yesWorks = yes
                upperCaseWorks = on
                worksAsWell = Enabled

                [Advanced]
                arrayWorkToo =
                    arrayElement1
                    arrayElement2
                valueLessKey",
                                                        new ConfigParserSettings
            {
                MultiLineValues = MultiLineValues.Simple | MultiLineValues.AllowValuelessKeys |
                                  MultiLineValues.QuoteDelimitedValues,
                Culture = new CultureInfo("en-US"),
            }
                                                        );

            // value
            Assert.Equal("value", configFileFromString.GetValue("Strings", "canBeIndented"));

            // quotes will be stripped
            Assert.Equal("quotes will be stripped", configFileFromString.GetValue("Strings", "andQuoted"));

            // 0.6
            Assert.Equal(0.6D, configFileFromString.GetValue("Numbers", "withD", 0D));

            // 2999
            Assert.Equal(2999D, configFileFromString.GetValue("Numbers", "dollars", 0D,
                                                              NumberStyles.AllowCurrencySymbol));

            // $2,999
            Assert.Equal("$2,999", configFileFromString.GetValue("Numbers", "dollars"));

            // all "True"
            Assert.True(configFileFromString.GetValue("boolean", "numericTrue", false));
            Assert.True(configFileFromString.GetValue("boolean", "textFalse", false));
            Assert.True(configFileFromString.GetValue("boolean", "yesWorks", false));
            Assert.True(configFileFromString.GetValue("boolean", "upperCaseWorks", false));
            Assert.True(configFileFromString.GetValue("boolean", "worksAsWell", false));

            // ["arrayElement1","arrayElement2"]
            Assert.Equal(new[] { "arrayElement1", "arrayElement2" },
                         configFileFromString.GetArrayValue("Advanced", "arrayWorkToo"));

            // null
            Assert.Null(configFileFromString.GetValue("Advanced", "valueLessKey"));
        }