Exemplo n.º 1
0
        public ComponentDetectorSupply(IDataSource dataSource)
        {
            string LowerCaseComparison(string s) => s.ToLower();

            supply = new Dictionary <ComponentType, Func <IDetectComponents> >
            {
                { ComponentType.Firstname, () => new InSetDetector(dataSource.CommonFirstNames(), ComponentType.Firstname, LowerCaseComparison) },
                { ComponentType.Surname, () => new InSetDetector(dataSource.CommonSurnames(), ComponentType.Surname, LowerCaseComparison) },
                { ComponentType.Link, () => new LinkDetector() },
                { ComponentType.Email, () => new EmailDetector() },
                { ComponentType.Date, () => new DateDetector() },
                { ComponentType.IpAddress, () => new IpAddressDetector() },
                { ComponentType.StreetSuffix, () => new InSetDetector(dataSource.StreetSuffixes(), ComponentType.StreetSuffix, LowerCaseComparison) },
                { ComponentType.CityTownBurgh, () => new InSetDetector(dataSource.Towns(), ComponentType.CityTownBurgh, LowerCaseComparison) },
                { ComponentType.County, () => new InSetDetector(dataSource.Countries(), ComponentType.Country, LowerCaseComparison) },
                { ComponentType.PostcodeInward, () => new InwardPostcodeDetector() },
                { ComponentType.PostcodeOutward, () => new OutwardPostcodeDetector() },
                { ComponentType.PostCodeFull, () => new RegexDetector(RegexConstants.FullPostCode, ComponentType.PostCodeFull) },
                { ComponentType.FlatWord, () => new WordDetector("flat", ComponentType.FlatWord) },
                { ComponentType.Number, () => new NumberDetector() },
                { ComponentType.NonDictionaryWord, () => new NotInSetDetector(dataSource.DictionaryWords(), ComponentType.NonDictionaryWord, LowerCaseComparison) },
            };
        }