BogaNet 1.4.0
Loading...
Searching...
No Matches
Public Member Functions | Static Protected Member Functions | Static Protected Attributes | Properties | Events | List of all members
BogaNet.BWF.Filter.DomainFilter Class Reference

Filter to remove domains (urls/emails etc.). More...

Inheritance diagram for BogaNet.BWF.Filter.DomainFilter:
BogaNet.Util.Singleton< DomainFilter > BogaNet.BWF.Filter.IDomainFilter BogaNet.BWF.Filter.ISourceFilter BogaNet.BWF.Filter.IFilter

Public Member Functions

virtual bool Remove (string srcName)
 Removes a source and assigned data.
 
virtual bool ContainsSource (string srcName)
 Checks if a given source name exists in the filter.
 
virtual void Clear ()
 Clears all sources.
 
virtual void Load (Dictionary< string, string[]> dataDict)
 Load sources from a given Dictionary.
 
virtual bool LoadFiles (params Tuple< string, string >[] files)
 Load source files (CSV) from a given path.
 
virtual async Task< bool > LoadFilesAsync (params Tuple< string, string >[] files)
 Load source files (CSV) from a given path asynchronously.
 
virtual bool LoadFilesFromUrl (params Tuple< string, string >[] urls)
 Load source files (CSV) from given URLs.
 
virtual async Task< bool > LoadFilesFromUrlAsync (params Tuple< string, string >[] urls)
 Load source files (CSV) from given URLs asynchronously.
 
virtual void Add (string srcName, params string[] domains)
 Adds a source with domains.
 
virtual bool Contains (string text, params string[]? sourceNames)
 Searches for bad words in a text.
 
virtual List< string > GetAll (string text, params string[]? sourceNames)
 Searches for bad words in a text.
 
virtual string ReplaceAll (string text, params string[]? sourceNames)
 Searches and replaces all bad words in a text.
 
- Public Member Functions inherited from BogaNet.BWF.Filter.ISourceFilter
delegate void FilesLoaded (params Tuple< string, string >[] files)
 Delegate for the load status of the files.
 

Static Protected Member Functions

static void logFilterNotReady ()
 
static void logSourceNotFound (string res)
 

Static Protected Attributes

const string DOMAIN_REGEX_START = @"\b{0,1}((ht|f)tp(s?)\:\/\/)?[\w\-\.\@]*[\.]"
 
const string DOMAIN_REGEX_END = @"(:\d{1,5})?(\/|\b)"
 
const RegexOptions REGEX_IC = RegexOptions.IgnoreCase
 
const RegexOptions REGEX_CI = RegexOptions.CultureInvariant
 
const RegexOptions REGEX_COMPILED = RegexOptions.Compiled
 

Properties

virtual int Count [get]
 Current count of sources from the filter.
 
virtual List< string > SourceNames [get]
 All source names of the current filter.
 
virtual bool IsLoaded [get]
 Is the filter loaded?
 
virtual char[] ReplaceCharacters = ['*'] [get, set]
 Replace characters for domains.
 
- Properties inherited from BogaNet.Util.Singleton< DomainFilter >
static T Instance [get]
 
- Properties inherited from BogaNet.BWF.Filter.IDomainFilter
- Properties inherited from BogaNet.BWF.Filter.ISourceFilter

Events

ISourceFilter.? FilesLoaded OnFilesLoaded
 
- Events inherited from BogaNet.BWF.Filter.ISourceFilter
FilesLoaded OnFilesLoaded
 Event triggered whenever the files are loaded.
 

Detailed Description

Filter to remove domains (urls/emails etc.).

Member Function Documentation

◆ Add()

virtual void BogaNet.BWF.Filter.DomainFilter.Add ( string srcName,
params string[] domains )
virtual

Adds a source with domains.

Parameters
srcNameSource name
domainsDomains for the source
Exceptions
ArgumentNullException

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ Clear()

virtual void BogaNet.BWF.Filter.DomainFilter.Clear ( )
virtual

Clears all sources.

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ Contains()

virtual bool BogaNet.BWF.Filter.DomainFilter.Contains ( string text,
params string?[] sourceNames )
virtual

Searches for bad words in a text.

Parameters
textText to check
sourceNamesRelevant sources (e.g. "english", optional)
Returns
True if a match was found

Implements BogaNet.BWF.Filter.IFilter.

◆ ContainsSource()

virtual bool BogaNet.BWF.Filter.DomainFilter.ContainsSource ( string srcName)
virtual

Checks if a given source name exists in the filter.

Parameters
srcNameSource name to check
Returns
True if the key exists in the filter
Exceptions
ArgumentNullException

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ GetAll()

virtual List< string > BogaNet.BWF.Filter.DomainFilter.GetAll ( string text,
params string?[] sourceNames )
virtual

Searches for bad words in a text.

Parameters
textText to check
sourceNamesRelevant sources (e.g. "english", optional)
Returns
List with all the matches

Implements BogaNet.BWF.Filter.IFilter.

◆ Load()

virtual void BogaNet.BWF.Filter.DomainFilter.Load ( Dictionary< string, string[]> dataDict)
virtual

Load sources from a given Dictionary.

Parameters
dataDictDictionary to load

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ LoadFiles()

virtual bool BogaNet.BWF.Filter.DomainFilter.LoadFiles ( params Tuple< string, string >[] files)
virtual

Load source files (CSV) from a given path.

Parameters
filesFiles to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ LoadFilesAsync()

virtual async Task< bool > BogaNet.BWF.Filter.DomainFilter.LoadFilesAsync ( params Tuple< string, string >[] files)
virtual

Load source files (CSV) from a given path asynchronously.

Parameters
filesFiles to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ LoadFilesFromUrl()

virtual bool BogaNet.BWF.Filter.DomainFilter.LoadFilesFromUrl ( params Tuple< string, string >[] urls)
virtual

Load source files (CSV) from given URLs.

Parameters
urlsURLs of files to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ LoadFilesFromUrlAsync()

virtual async Task< bool > BogaNet.BWF.Filter.DomainFilter.LoadFilesFromUrlAsync ( params Tuple< string, string >[] urls)
virtual

Load source files (CSV) from given URLs asynchronously.

Parameters
urlsURLs of files to load (Item1 = source name, Item2 = file)

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ logFilterNotReady()

static void BogaNet.BWF.Filter.DomainFilter.logFilterNotReady ( )
staticprotected

◆ logSourceNotFound()

static void BogaNet.BWF.Filter.DomainFilter.logSourceNotFound ( string res)
staticprotected

◆ Remove()

virtual bool BogaNet.BWF.Filter.DomainFilter.Remove ( string srcName)
virtual

Removes a source and assigned data.

Parameters
srcNameSource name to remove

returns>True if the operation was successful

Exceptions
ArgumentNullException

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ ReplaceAll()

virtual string BogaNet.BWF.Filter.DomainFilter.ReplaceAll ( string text,
params string?[] sourceNames )
virtual

Searches and replaces all bad words in a text.

Parameters
textText to check
sourceNamesRelevant sources (e.g. "english", optional)
Returns
Clean text

Implements BogaNet.BWF.Filter.IFilter.

Member Data Documentation

◆ DOMAIN_REGEX_END

const string BogaNet.BWF.Filter.DomainFilter.DOMAIN_REGEX_END = @"(:\d{1,5})?(\/|\b)"
staticprotected

◆ DOMAIN_REGEX_START

const string BogaNet.BWF.Filter.DomainFilter.DOMAIN_REGEX_START = @"\b{0,1}((ht|f)tp(s?)\:\/\/)?[\w\-\.\@]*[\.]"
staticprotected

◆ REGEX_CI

const RegexOptions BogaNet.BWF.Filter.DomainFilter.REGEX_CI = RegexOptions.CultureInvariant
staticprotected

◆ REGEX_COMPILED

const RegexOptions BogaNet.BWF.Filter.DomainFilter.REGEX_COMPILED = RegexOptions.Compiled
staticprotected

◆ REGEX_IC

const RegexOptions BogaNet.BWF.Filter.DomainFilter.REGEX_IC = RegexOptions.IgnoreCase
staticprotected

Property Documentation

◆ Count

virtual int BogaNet.BWF.Filter.DomainFilter.Count
get

Current count of sources from the filter.

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ IsLoaded

virtual bool BogaNet.BWF.Filter.DomainFilter.IsLoaded
get

Is the filter loaded?

Implements BogaNet.BWF.Filter.ISourceFilter.

◆ ReplaceCharacters

virtual char [] BogaNet.BWF.Filter.DomainFilter.ReplaceCharacters = ['*']
getset

Replace characters for domains.

Implements BogaNet.BWF.Filter.IDomainFilter.

◆ SourceNames

virtual List<string> BogaNet.BWF.Filter.DomainFilter.SourceNames
get

All source names of the current filter.

Returns
List with all source names of the current filter

Implements BogaNet.BWF.Filter.ISourceFilter.

Event Documentation

◆ OnFilesLoaded

ISourceFilter.? FilesLoaded BogaNet.BWF.Filter.DomainFilter.OnFilesLoaded

The documentation for this class was generated from the following file: