mirror of
https://github.com/ZuneDev/ZuneShell.dll.git
synced 2026-07-27 13:11:51 -07:00
79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: ZuneUI.RecipientHelper
|
|
// Assembly: ZuneShell, Version=4.7.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
|
// MVID: FC8028F3-A47B-4FB4-B35B-11D1752D8264
|
|
// Assembly location: C:\Program Files\Zune\ZuneShell.dll
|
|
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace ZuneUI
|
|
{
|
|
public class RecipientHelper : AutoCompleteHelper
|
|
{
|
|
private List<string> _validRecipients;
|
|
private string _errorMessage;
|
|
|
|
public RecipientHelper() => this._validRecipients = new List<string>();
|
|
|
|
public void ClearState()
|
|
{
|
|
this._validRecipients = new List<string>();
|
|
this.Entry = string.Empty;
|
|
this.ErrorMessage = null;
|
|
}
|
|
|
|
public static bool ValidZuneTag(string tag) => ZuneTagHelper.IsValid(tag);
|
|
|
|
public static bool ValidEmail(string email) => EmailHelper.IsValid(email);
|
|
|
|
public bool ValidateAll(bool allowEmailRecipients) => this.Validate(this.Entry, allowEmailRecipients);
|
|
|
|
public string ErrorMessage
|
|
{
|
|
get => this._errorMessage;
|
|
private set
|
|
{
|
|
if (!(this._errorMessage != value))
|
|
return;
|
|
this._errorMessage = value;
|
|
this.FirePropertyChanged(nameof(ErrorMessage));
|
|
}
|
|
}
|
|
|
|
public IList ValidRecipients => _validRecipients;
|
|
|
|
private bool Validate(string entry, bool allowEmailRecipients)
|
|
{
|
|
bool flag = true;
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
this._validRecipients.Clear();
|
|
if (entry != null)
|
|
{
|
|
string[] strArray = entry.Split(s_entrySeparators);
|
|
for (int index = 0; index < strArray.Length; ++index)
|
|
{
|
|
string str = strArray[index].Trim();
|
|
if (str.Length != 0)
|
|
{
|
|
if (!ValidZuneTag(str) && (!allowEmailRecipients || !ValidEmail(str)))
|
|
{
|
|
flag = false;
|
|
if (index != 0)
|
|
stringBuilder.Append(' ');
|
|
stringBuilder.Append(str);
|
|
}
|
|
else
|
|
this._validRecipients.Add(str);
|
|
}
|
|
}
|
|
}
|
|
this.ErrorMessage = flag ? null : string.Format(Shell.LoadString(allowEmailRecipients ? StringId.IDS_COMPOSE_MESSAGE_ERROR_FRIENDS : StringId.IDS_COMPOSE_MESSAGE_ERROR_FRIENDS_NO_EMAIL), stringBuilder.ToString());
|
|
return flag;
|
|
}
|
|
|
|
public static IList MakeStringList() => new List<string>();
|
|
}
|
|
}
|