wzp
2022-10-25 1961452ebc018cf758924f26d9c7aa0b31495227
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
 
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);
    }
  }
}