mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-05-21 00:16:35 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -4,164 +4,164 @@ using System.Linq;
|
|||
|
||||
namespace TINK.Model.User.Account
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds the state of mail and password and information about some invalid parts if there are.
|
||||
/// </summary>
|
||||
public class State
|
||||
{
|
||||
/// <summary>
|
||||
/// Consider state to be invalid after construction.
|
||||
/// </summary>
|
||||
private Elements m_eElements = Elements.None;
|
||||
/// <summary>
|
||||
/// Holds the state of mail and password and information about some invalid parts if there are.
|
||||
/// </summary>
|
||||
public class State
|
||||
{
|
||||
/// <summary>
|
||||
/// Consider state to be invalid after construction.
|
||||
/// </summary>
|
||||
private Elements m_eElements = Elements.None;
|
||||
|
||||
private Dictionary<Elements, string> m_oDescription = new Dictionary<Elements, string>();
|
||||
private Dictionary<Elements, string> m_oDescription = new Dictionary<Elements, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs object to state all entries are valid.
|
||||
/// </summary>
|
||||
public State()
|
||||
{
|
||||
m_eElements = Elements.Account;
|
||||
/// <summary>
|
||||
/// Constructs object to state all entries are valid.
|
||||
/// </summary>
|
||||
public State()
|
||||
{
|
||||
m_eElements = Elements.Account;
|
||||
|
||||
m_oDescription = new Dictionary<Elements, string>
|
||||
{
|
||||
{ Elements.None, string.Empty },
|
||||
{ Elements.Account, string.Empty }
|
||||
};
|
||||
}
|
||||
m_oDescription = new Dictionary<Elements, string>
|
||||
{
|
||||
{ Elements.None, string.Empty },
|
||||
{ Elements.Account, string.Empty }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs object to state some/ all elements are invalid.
|
||||
/// </summary>
|
||||
/// <param name="p_oValidParts">Specifies the parts which are invalid.</param>
|
||||
/// <param name="p_oDescription">Description of invalid parts.</param>
|
||||
public State(Elements p_oValidParts, Dictionary<Elements, string> p_oDescription)
|
||||
{
|
||||
m_eElements = p_oValidParts;
|
||||
/// <summary>
|
||||
/// Constructs object to state some/ all elements are invalid.
|
||||
/// </summary>
|
||||
/// <param name="p_oValidParts">Specifies the parts which are invalid.</param>
|
||||
/// <param name="p_oDescription">Description of invalid parts.</param>
|
||||
public State(Elements p_oValidParts, Dictionary<Elements, string> p_oDescription)
|
||||
{
|
||||
m_eElements = p_oValidParts;
|
||||
|
||||
m_oDescription = p_oDescription ?? new Dictionary<Elements, string>();
|
||||
m_oDescription = p_oDescription ?? new Dictionary<Elements, string>();
|
||||
|
||||
// Ensure consistency
|
||||
foreach (Elements l_oElement in Enum.GetValues(typeof(Elements)))
|
||||
{
|
||||
if (!m_oDescription.ContainsKey(l_oElement))
|
||||
{
|
||||
switch (l_oElement)
|
||||
{
|
||||
case Elements.Account:
|
||||
case Elements.None:
|
||||
continue;
|
||||
// Ensure consistency
|
||||
foreach (Elements l_oElement in Enum.GetValues(typeof(Elements)))
|
||||
{
|
||||
if (!m_oDescription.ContainsKey(l_oElement))
|
||||
{
|
||||
switch (l_oElement)
|
||||
{
|
||||
case Elements.Account:
|
||||
case Elements.None:
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
m_oDescription.Add(l_oElement, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_oDescription.Add(l_oElement, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if account is valid.
|
||||
/// </summary>
|
||||
public bool IsValid { get { return ValidElement == Elements.Account; } }
|
||||
/// <summary>
|
||||
/// True if account is valid.
|
||||
/// </summary>
|
||||
public bool IsValid { get { return ValidElement == Elements.Account; } }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies if both mail and password are valid, one of them or none.
|
||||
/// </summary>
|
||||
public Elements ValidElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_eElements;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Specifies if both mail and password are valid, one of them or none.
|
||||
/// </summary>
|
||||
public Elements ValidElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_eElements;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds the message about invalid elements.
|
||||
/// </summary>
|
||||
public Dictionary<Elements, string> Description
|
||||
{
|
||||
get
|
||||
{
|
||||
var l_oUserFriendlyDescription = new Dictionary<Elements, string>();
|
||||
foreach (Elements l_oElement in Enum.GetValues(typeof(Elements)))
|
||||
{
|
||||
switch (l_oElement)
|
||||
{
|
||||
case Elements.Account:
|
||||
case Elements.None:
|
||||
continue;
|
||||
/// <summary>
|
||||
/// Holds the message about invalid elements.
|
||||
/// </summary>
|
||||
public Dictionary<Elements, string> Description
|
||||
{
|
||||
get
|
||||
{
|
||||
var l_oUserFriendlyDescription = new Dictionary<Elements, string>();
|
||||
foreach (Elements l_oElement in Enum.GetValues(typeof(Elements)))
|
||||
{
|
||||
switch (l_oElement)
|
||||
{
|
||||
case Elements.Account:
|
||||
case Elements.None:
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
l_oUserFriendlyDescription.Add(
|
||||
l_oElement,
|
||||
m_oDescription.ContainsKey(l_oElement) ? m_oDescription[l_oElement] : string.Empty);
|
||||
}
|
||||
l_oUserFriendlyDescription.Add(
|
||||
l_oElement,
|
||||
m_oDescription.ContainsKey(l_oElement) ? m_oDescription[l_oElement] : string.Empty);
|
||||
}
|
||||
|
||||
l_oUserFriendlyDescription.Add(
|
||||
Elements.Account,
|
||||
string.Join(";", l_oUserFriendlyDescription.Where(x => x.Value.Length > 0).Select(x => x.Value).ToArray()));
|
||||
l_oUserFriendlyDescription.Add(
|
||||
Elements.Account,
|
||||
string.Join(";", l_oUserFriendlyDescription.Where(x => x.Value.Length > 0).Select(x => x.Value).ToArray()));
|
||||
|
||||
return l_oUserFriendlyDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
return l_oUserFriendlyDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies if a password is valid or not.
|
||||
/// </summary>
|
||||
/// <param name="p_strMail"></param>
|
||||
/// <param name="p_strPassword"></param>
|
||||
/// <returns></returns>
|
||||
public delegate State PasswordValidator(string p_strMail, string p_strPassword);
|
||||
/// <summary>
|
||||
/// Verifies if a password is valid or not.
|
||||
/// </summary>
|
||||
/// <param name="p_strMail"></param>
|
||||
/// <param name="p_strPassword"></param>
|
||||
/// <returns></returns>
|
||||
public delegate State PasswordValidator(string p_strMail, string p_strPassword);
|
||||
|
||||
public static class Validator
|
||||
{
|
||||
public static State ValidateMailAndPasswordDelegate(string p_strMail, string p_strPassword)
|
||||
{
|
||||
var l_oElements = Elements.None;
|
||||
var l_oDescription = new Dictionary<Elements, string>();
|
||||
public static class Validator
|
||||
{
|
||||
public static State ValidateMailAndPasswordDelegate(string p_strMail, string p_strPassword)
|
||||
{
|
||||
var l_oElements = Elements.None;
|
||||
var l_oDescription = new Dictionary<Elements, string>();
|
||||
|
||||
// Validate mail address.
|
||||
if (string.IsNullOrEmpty(p_strMail))
|
||||
{
|
||||
l_oDescription.Add(Elements.Mail, "Email Addresse darf nicht leer sein.");
|
||||
}
|
||||
else if (p_strMail.ToString().Split('@').Length < 2)
|
||||
{
|
||||
l_oDescription.Add(Elements.Mail, "Email Adresse mit Zeichen \"@\" enthalten.");
|
||||
}
|
||||
else if (p_strMail.ToString().Split('@')[0].Length <= 0)
|
||||
{
|
||||
l_oDescription.Add(Elements.Mail, "Benutzername in Email Adresse darf nicht leer sein.");
|
||||
}
|
||||
else if (p_strMail.ToString().Split('@')[1].Length <= 0)
|
||||
{
|
||||
// Data has been entered
|
||||
l_oDescription.Add(Elements.Mail, "Domain- Name in Email Adresse darf nicht leer sein.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input mail address is ok
|
||||
l_oElements = Elements.Mail;
|
||||
l_oDescription.Add(Elements.Mail, string.Empty);
|
||||
}
|
||||
// Validate mail address.
|
||||
if (string.IsNullOrEmpty(p_strMail))
|
||||
{
|
||||
l_oDescription.Add(Elements.Mail, "Email Addresse darf nicht leer sein.");
|
||||
}
|
||||
else if (p_strMail.ToString().Split('@').Length < 2)
|
||||
{
|
||||
l_oDescription.Add(Elements.Mail, "Email Adresse mit Zeichen \"@\" enthalten.");
|
||||
}
|
||||
else if (p_strMail.ToString().Split('@')[0].Length <= 0)
|
||||
{
|
||||
l_oDescription.Add(Elements.Mail, "Benutzername in Email Adresse darf nicht leer sein.");
|
||||
}
|
||||
else if (p_strMail.ToString().Split('@')[1].Length <= 0)
|
||||
{
|
||||
// Data has been entered
|
||||
l_oDescription.Add(Elements.Mail, "Domain- Name in Email Adresse darf nicht leer sein.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input mail address is ok
|
||||
l_oElements = Elements.Mail;
|
||||
l_oDescription.Add(Elements.Mail, string.Empty);
|
||||
}
|
||||
|
||||
// Validate password.
|
||||
if (string.IsNullOrEmpty(p_strPassword) || p_strPassword.Length < 8)
|
||||
{
|
||||
// Data has been entered
|
||||
l_oDescription.Add(Elements.Password, "Passwort is zu kurz.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Password is ok
|
||||
l_oElements |= Elements.Password;
|
||||
l_oDescription.Add(Elements.Password, string.Empty);
|
||||
}
|
||||
// Validate password.
|
||||
if (string.IsNullOrEmpty(p_strPassword) || p_strPassword.Length < 8)
|
||||
{
|
||||
// Data has been entered
|
||||
l_oDescription.Add(Elements.Password, "Passwort is zu kurz.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Password is ok
|
||||
l_oElements |= Elements.Password;
|
||||
l_oDescription.Add(Elements.Password, string.Empty);
|
||||
}
|
||||
|
||||
return new State(l_oElements, l_oDescription);
|
||||
}
|
||||
}
|
||||
return new State(l_oElements, l_oDescription);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue