In this article, you will learn how to create a spam filter on your mail application. You will also see how to filter your mail based on whether the mail tells about a particular topic or not.
- SpamFilterSample.zip
- SpamFilterSample
- HigLabo.Mail.SampleApplication
- HigLabo.Mail
- Async
- bin
- Debug
- Release
- HigLabo.Mail.dll
- HigLabo.Net.dll
- Newtonsoft.Json.dll
- Common
- HigLabo.Mail.csproj
- HigLabo.Mail.csproj.user
- HigLabo.Mail.csproj.vspscc
- Imap
- obj
- Pop3
- Properties
- Smtp
- HigLabo.Net
- bin
- Debug
- de
- es
- fr
- it
- ja
- ko
- ru
- zh-Hans
- zh-Hant
- Release
- de
- System.Xml.Linq.resources.dll
- es
- System.Xml.Linq.resources.dll
- fr
- System.Xml.Linq.resources.dll
- HigLabo.Net.dll
- HigLabo.Net.Silverlight.dll
- HigLabo.Net.WindowsPhone7.dll
- it
- System.Xml.Linq.resources.dll
- ja
- System.Xml.Linq.resources.dll
- ko
- System.Xml.Linq.resources.dll
- Newtonsoft.Json.dll
- Newtonsoft.Json.Silverlight.dll
- Newtonsoft.Json.WindowsPhone7.dll
- ru
- System.Xml.Linq.resources.dll
- System.Xml.Linq.dll
- zh-Hans
- System.Xml.Linq.resources.dll
- zh-Hant
- System.Xml.Linq.resources.dll
- Core
- Extensions
- HigLabo.Net.csproj
- HigLabo.Net.csproj.user
- HigLabo.Net.csproj.vspscc
- HigLabo.Net.Silverlight.csproj
- HigLabo.Net.Silverlight.csproj.user
- HigLabo.Net.Silverlight.csproj.vspscc
- HigLabo.Net.WindowsPhone7.csproj
- HigLabo.Net.WindowsPhone7.csproj.user
- HigLabo.Net.WindowsPhone7.csproj.vspscc
- Http
- OAuth
- obj
- Properties
- Socket
- Reference
- BayesianFilter.dll
- bin
- Debug
- Reference.dll
- Release
- HtmlAgilityPack.dll
- obj
- Debug
- TempPE
- Properties
- Reference.csproj
- Reference.csproj.user
- SpamFilterSample
- SpamFilterSample-noexe.zip
|
using System;
using System.Xml.Linq;
namespace HigLabo.Net.Extensions
{
/// <summary>
///
/// </summary>
public static class XmlParserExtensions
{
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static String CastElementToString(this XElement element, String key)
{
if (element.Element(key) == null) { return ""; }
return element.Element(key).Value;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static Boolean? CastElementToBoolean(this XElement element, String key)
{
Boolean x = false;
if (element.Element(key) == null) { return null; }
if (Boolean.TryParse(element.Element(key).Value, out x) == true)
{
return x;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static Int32? CastElementToInt32(this XElement element, String key)
{
Int32 x = 0;
if (element.Element(key) == null) { return null; }
if (Int32.TryParse(element.Element(key).Value, out x) == true)
{
return x;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static Int64? CastElementToInt64(this XElement element, String key)
{
Int64 x = 0;
if (element.Element(key) == null) { return null; }
if (Int64.TryParse(element.Element(key).Value, out x) == true)
{
return x;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static String CastAttributeToString(this XElement element, String key)
{
if (element.Attribute(key) == null) { return ""; }
return element.Attribute(key).Value;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static Boolean? CastAttributeToBoolean(this XElement element, String key)
{
Boolean x = false;
if (element.Attribute(key) == null) { return null; }
if (Boolean.TryParse(element.Attribute(key).Value, out x) == true)
{
return x;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static Int32? CastAttributeToInt32(this XElement element, String key)
{
Int32 x = 0;
if (element.Attribute(key) == null) { return null; }
if (Int32.TryParse(element.Attribute(key).Value, out x) == true)
{
return x;
}
return null;
}
/// <summary>
///
/// </summary>
/// <param name="element"></param>
/// <param name="key"></param>
/// <returns></returns>
public static Int64? CastAttributeToInt64(this XElement element, String key)
{
Int64 x = 0;
if (element.Attribute(key) == null) { return null; }
if (Int64.TryParse(element.Attribute(key).Value, out x) == true)
{
return x;
}
return null;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.