emailfield.cs

来自「pureIRCd是一个用c语音写的irc(RFC459)服务,可以给您带来很多的」· CS 代码 · 共 93 行

CS
93
字号
using SDP;
using System;

/// <summary>
/// An EMail represents an e= field contained within a SessionDescription.
/// </summary>
public class EMailField : Field
{
    private string username;
    /// <summary>
    /// Gets the username portion of this email address.
    /// </summary>
    public string Username
    {
        get { return this.username; }
    }


    private string displayname;
    /// <summary>
    /// Gets the display name.
    /// </summary>
    public string DisplayName
    {
        get { return this.displayname; }
    }

    private string host;
    /// <summary>
    /// Gets the host.
    /// </summary>
    public string Host
    {
        get { return this.host; }
    }

    /// <summary>
    /// Gets the full string representation of the email address: username@host (displayname)
    /// </summary>
    public string EmailAddress
    {
        get { return this.Value; }
    }

    /// <summary>
    /// Creates a new EMailField.
    /// </summary>
    /// <param name="value">The value portion of the field.</param>
    public EMailField(string value)
        : base("e=" + value)
    {
        string val = base.Value;
        int i = val.IndexOf(' ');
        if (i > 0)
        {
            this.displayname = val.Substring(i + 1).Trim(' ', '\r', '\n', '(', ')');
            val = val.Remove(i + 1);
        }
        string[] parts = val.Split('@');
        this.username = parts[0];
        this.host = parts[1];
    }

    /// <summary>
    /// Creates a new EMailField.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <param name="host">The host.</param>
    public EMailField(string username, string host) : this(username + "@" + host) { }

    /// <summary>
    /// Creates a new EMailField.
    /// </summary>
    /// <param name="username">The username.</param>
    /// <param name="host">The host.</param>
    /// <param name="displayname">The display name.</param>
    public EMailField(string username, string host, string displayname) : this(username + "@" + host + " (" + displayname + ")") { }

    /// <summary>
    /// Gets the value portion of this field.
    /// </summary>
    public override string Value
    {
        get
        {
            string s = this.username + "@" + this.host;
            if (!String.IsNullOrEmpty(s)) s = s + " (" + this.displayname + ")";
            return s;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?