keyfield.cs

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

CS
54
字号
using SDP;
using System;

/// <summary>
/// A Key represents the k= field contained within either a MediaDescription or a SessionDescription.
/// </summary>
public class KeyField : Field
{
    private string method;
    /// <summary>
    /// Gets the method of encryption to use. See <see cref="EncryptionMethods"/>
    /// </summary>
    public string Method
    {
        get { return this.method; }
    }

    /// <summary>
    /// Determines whether or not a key is present.
    /// </summary>
    public bool HasKey
    {
        get { return !String.IsNullOrEmpty(this.method); }
    }

    private string key;
    /// <summary>
    /// Gets the encryption key, if there is one.
    /// </summary>
    public string Key
    {
        get { return this.key; }
    }
    
    /// <summary>
    /// Creates a new KeyField.
    /// </summary>
    /// <param name="value">The value portion of the field.</param>
    public KeyField(string value)
        : base("k=" + value)
    {
        string val = base.Value;
        string[] parts = val.Split(':');
        this.method = parts[0];
        if (parts.Length > 1) this.key = parts[1];
    }

    /// <summary>
    /// Creates a new KeyField.
    /// </summary>
    /// <param name="method">The encryption method.</param>
    /// <param name="key">The key.</param>
    public KeyField(string method, string key) : this(method + (String.IsNullOrEmpty(key) ? "" : ":" + key)) { }
}

⌨️ 快捷键说明

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