|
|
using Newtonsoft.Json;
|
using System;
|
using System.Text.RegularExpressions;
|
|
namespace Mytek.UMCLib
|
{
|
[Serializable]
|
public class MessageActor
|
{
|
public string SID { get; private set; }
|
|
public string Logo { get; private set; }
|
|
public string NickName { get; private set; }
|
|
public string ClientID { get; private set; }
|
|
public string OpenID { get; private set; }
|
|
public string Mobile { get; private set; }
|
|
public string Email { get; private set; }
|
|
public bool IsEmailAvailable { get; private set; }
|
|
public bool IsCappAvailable { get; private set; }
|
|
public bool IsWxAvailable { get; private set; }
|
|
public bool IsMobileAvailable { get; private set; }
|
|
private MessageActor()
|
{
|
this.IsEmailAvailable = false;
|
this.IsCappAvailable = false;
|
this.IsWxAvailable = false;
|
this.IsMobileAvailable = false;
|
}
|
|
public static MessageActor CreateActor(string sid)
|
{
|
return new MessageActor()
|
{
|
SID = sid
|
};
|
}
|
|
public MessageActor AppendCapp(string logo, string nickname, string clientID)
|
{
|
this.ClientID = clientID;
|
this.Logo = logo;
|
this.NickName = nickname;
|
this.IsCappAvailable = true;
|
return this;
|
}
|
|
public MessageActor AppendWx(string openID)
|
{
|
this.OpenID = openID;
|
this.IsWxAvailable = !string.IsNullOrEmpty(openID);
|
return this;
|
}
|
|
public MessageActor AppendMobile(string mobile)
|
{
|
this.Mobile = mobile;
|
this.IsMobileAvailable = !string.IsNullOrEmpty(mobile) && Regex.IsMatch(mobile, "1\\d{10}");
|
return this;
|
}
|
|
public MessageActor AppendEmail(string email, string displayName)
|
{
|
this.Email = email;
|
this.NickName = displayName;
|
this.IsEmailAvailable = !string.IsNullOrEmpty(email) && Regex.IsMatch(email, "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
|
return this;
|
}
|
|
public override string ToString()
|
{
|
return JsonConvert.SerializeObject((object) this);
|
}
|
}
|
}
|