本文整理汇总了C#中Jid.ThrowIfNull方法的典型用法代码示例。如果您正苦于以下问题:C# Jid.ThrowIfNull方法的具体用法?C# Jid.ThrowIfNull怎么用?C# Jid.ThrowIfNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jid
的用法示例。
在下文中一共展示了Jid.ThrowIfNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageEventArgs
/// <summary>
/// Initializes a new instance of the MessageEventArgs class.
/// </summary>
/// <exception cref="ArgumentNullException">The jid parameter or the message
/// parameter is null.</exception>
public MessageEventArgs(Jid jid, Message message)
{
jid.ThrowIfNull("jid");
message.ThrowIfNull("message");
Jid = jid;
Message = message;
}
示例2: StatusEventArgs
/// <summary>
/// Initializes a new instance of the StatusEventArgs class.
/// </summary>
/// <exception cref="ArgumentNullException">The jid parameter or the status
/// parameter is null.</exception>
public StatusEventArgs(Jid jid, Status status)
{
jid.ThrowIfNull("jid");
status.ThrowIfNull("status");
Jid = jid;
Status = status;
}
示例3: MoodChangedEventArgs
/// <summary>
/// Initializes a new instance of the MoodChangedEventArgs class.
/// </summary>
/// <param name="jid">The JID of the XMPP entity that published the
/// mood information.</param>
/// <param name="mood">One of the values from the Mood enumeration.</param>
/// <param name="description">A natural-language description of, or
/// reason for, the mood.</param>
/// <exception cref="ArgumentNullException">The jid parameter is
/// null.</exception>
public MoodChangedEventArgs(Jid jid, Mood mood, string description = null)
{
jid.ThrowIfNull("jid");
Jid = jid;
Mood = mood;
Description = description;
}
示例4: XmppItem
/// <summary>
/// Initializes a new instance of the Item class.
/// </summary>
/// <param name="jid">The JID of the item.</param>
/// <param name="node">The node identifier of the item.</param>
/// <param name="name">The name of the item.</param>
/// <exception cref="ArgumentNullException">The jid parameter is
/// null.</exception>
public XmppItem(Jid jid, string node = null, string name = null)
{
jid.ThrowIfNull("jid");
Jid = jid;
Node = node;
Name = name;
}
示例5: JidPrivacyRule
/// <summary>
/// Initializes a new instance of the PrivacyRule class.
/// </summary>
/// <param name="jid">The JID the privacy rule applies to.</param>
/// <param name="allow">True to allow entities affected by this rule; Otherwise
/// false.</param>
/// <param name="order">The order of the privacy rule.</param>
/// <param name="granularity">Specifies which kinds of stanzas should be
/// allowed or blocked, respectively.</param>
/// <exception cref="ArgumentNullException">The jid parameter is null.</exception>
public JidPrivacyRule(Jid jid, bool allow, uint order,
PrivacyGranularity granularity = 0)
: base(allow, order, granularity)
{
jid.ThrowIfNull("jid");
Jid = jid;
}
示例6: ArchivedChatId
/// <summary>
/// Create an archived chat id
/// </summary>
/// <param name="with">The id of the entity that the conversation was with</param>
/// <param name="start">The start date of the conversation</param>
public ArchivedChatId(Jid with, DateTimeOffset start)
{
with.ThrowIfNull("with");
With = with;
Start = start;
}
示例7: Streamhost
/// <summary>
/// Initializes a new instance of the Streamhost class.
/// </summary>
/// <param name="jid">The JID of the streamhost.</param>
/// <param name="host">The hostname of the streamhost.</param>
/// <param name="port">The port on which the streamhost is accepting
/// connections.</param>
/// <exception cref="ArgumentNullException">The jid parameter or the
/// host parameter is null.</exception>
/// <exception cref="ArgumentException">The host parameter is the empty
/// string.</exception>
/// <exception cref="ArgumentOutOfRangeException">The port parameter is
/// not between 0 and 65535.</exception>
public Streamhost(Jid jid, string host, int port) {
jid.ThrowIfNull("jid");
host.ThrowIfNullOrEmpty("host");
port.ThrowIfOutOfRange("port", 0, 65535);
Jid = jid;
Host = host;
Port = port;
}
示例8: ActivityChangedEventArgs
/// <summary>
/// Initializes a new instance of the ActivityChangedEventArgs class.
/// </summary>
/// <param name="jid">The JID of the XMPP entity that published the
/// activity information.</param>
/// <param name="activity">One of the values from the GeneralActivity
/// enumeration.</param>
/// <param name="specific">A value from the SpecificActivity enumeration
/// best describing the user's activity in more detail.</param>
/// <param name="description">A natural-language description of, or
/// reason for, the activity.</param>
/// <exception cref="ArgumentNullException">The jid parameter is
/// null.</exception>
public ActivityChangedEventArgs(Jid jid, GeneralActivity activity,
SpecificActivity specific = SpecificActivity.Other,
string description = null) {
jid.ThrowIfNull("jid");
Jid = jid;
Activity = activity;
Specific = specific;
Description = description;
}
示例9: GetAttention
/// <summary>
/// Gets the attention of the XMPP user with the specified JID.
/// </summary>
/// <param name="jid">The JID of the user to grab the attention of.</param>
/// <param name="message">A message to sent along.</param>
/// <exception cref="ArgumentNullException">The jid parameter
/// is null.</exception>
/// <exception cref="NotSupportedException">The XMPP entity with
/// the specified JID does not support the 'Attention' XMPP
/// extension.</exception>
public void GetAttention(Jid jid, string message = null) {
jid.ThrowIfNull("jid");
if(!ecapa.Supports(jid, Extension.Attention)) {
throw new NotSupportedException("The XMPP entity does not support the " +
"'Attention' extension.");
}
Im.Message m = new Im.Message(jid, message);
// Add the 'attention' element to the message.
m.Data.Child(Xml.Element("attention", "urn:xmpp:attention:0"));
im.SendMessage(m);
}
示例10: Message
/// <summary>
/// Initializes a new instance of the Message class.
/// </summary>
/// <param name="to">The JID of the intended recipient.</param>
/// <param name="body">The content of the message.</param>
/// <param name="subject">The subject of the message.</param>
/// <param name="thread">The conversation thread this message belongs to.</param>
/// <param name="type">The type of the message. Can be one of the values from
/// the MessagType enumeration.</param>
/// <param name="language">The language of the XML character data of
/// the stanza.</param>
/// <exception cref="ArgumentNullException">The to parameter is null.</exception>
/// <exception cref="ArgumentException">The body parameter is the empty string.</exception>
public Message(Jid to, string body = null, string subject = null, string thread = null,
MessageType type = MessageType.Normal, CultureInfo language = null)
: base(to, null, null, null, language)
{
to.ThrowIfNull("to");
AlternateSubjects = new XmlDictionary(element, "subject", "xml:lang");
AlternateBodies = new XmlDictionary(element, "body", "xml:lang");
Type = type;
Body = body;
Subject = subject;
Thread = thread;
}
示例11: FileTransfer
/// <summary>
/// Initializes a new instance of the FileTransfer class.
/// </summary>
/// <param name="from">The JID of the XMPP entity that is sending the
/// file.</param>
/// <param name="to">The JID of the XMPP entity that is receiving the
/// file.</param>
/// <param name="name">The name of the file.</param>
/// <param name="size">The size of the file, in bytes.</param>
/// <param name="sessionId">The session id associated with the
/// file-transfer.</param>
/// <param name="description">A description of the file.</param>
/// <param name="transferred">The number of bytes transferred.</param>
/// <exception cref="ArgumentNullException">The from parameter or the to
/// parameter or the name parameter is null.</exception>
/// <exception cref="ArgumentOutOfRangeException">The size parameter
/// is negative.</exception>
internal FileTransfer(Jid from, Jid to, string name, long size,
string sessionId = null, string description = null, long transferred = 0) {
from.ThrowIfNull("from");
to.ThrowIfNull("to");
name.ThrowIfNull("name");
size.ThrowIfOutOfRange("size", 0, Int64.MaxValue);
transferred.ThrowIfOutOfRange("transferred", 0, size);
From = from;
To = to;
Name = name;
Size = size;
SessionId = sessionId;
Description = description;
Transferred = transferred;
}
示例12: RosterItem
/// <summary>
/// Initializes a new instance of the RosterItem class.
/// </summary>
/// <param name="jid">The JID of the user this item will be associated
/// with.</param>
/// <param name="name">The nickname with which to associate the JID.</param>
/// <param name="state">One of the values from the SubscriptionState
/// enumeration.</param>
/// <param name="pending">True if the user has requested subscription but
/// has not received the contact's response.</param>
/// <param name="groups">An enumerable collection of groups to categorize
/// this item in.</param>
/// <exception cref="ArgumentNullException">The jid parameter is null.</exception>
internal RosterItem(Jid jid, string name, SubscriptionState state,
bool pending, IEnumerable<string> groups) {
jid.ThrowIfNull("jid");
Jid = jid;
Name = name;
if (groups != null) {
foreach (string s in groups) {
if (String.IsNullOrEmpty(s))
continue;
this.groups.Add(s);
}
}
SubscriptionState = state;
Pending = pending;
}
示例13: Unblock
/// <summary>
/// Unblocks all communication to and from the XMPP entity with the specified
/// JID.
/// </summary>
/// <param name="jid">The JID of the XMPP entity to unblock.</param>
/// <exception cref="ArgumentNullException">The jid parameter is
/// null.</exception>
/// <exception cref="NotSupportedException">The server does not support the
/// 'Blocking Command' extension and does not support privacy-list management.
/// </exception>
/// <exception cref="XmppErrorException">The server returned an XMPP error code.
/// Use the Error property of the XmppErrorException to obtain the specific
/// error condition.</exception>
/// <exception cref="XmppException">The server returned invalid data or another
/// unspecified XMPP error occurred.</exception>
/// <exception cref="InvalidOperationException">The XmppClient instance is
/// not connected to a remote host.</exception>
/// <exception cref="InvalidOperationException">The XmppClient instance is
/// not connected to a remote host.</exception>
/// <exception cref="ObjectDisposedException">The XmppClient object
/// has been disposed.</exception>
public void Unblock(Jid jid)
{
AssertValid();
jid.ThrowIfNull("jid");
// If our server supports the 'Blocking Command' extension, we can just
// use that.
if (block.Supported)
block.Unblock(jid);
else
{
// Privacy list blocking. If our server doesn't support privacy lists, we're
// out of luck.
PrivacyList privacyList = null;
string name = im.GetDefaultPrivacyList();
if (name != null)
privacyList = im.GetPrivacyList(name);
// If no default list has been set, look for a 'blocklist' list.
foreach (var list in im.GetPrivacyLists())
{
if (list.Name == "blocklist")
privacyList = list;
}
// No blocklist found.
if (privacyList == null)
return;
ISet<JidPrivacyRule> set = new HashSet<JidPrivacyRule>();
foreach (var rule in privacyList)
{
if (rule is JidPrivacyRule)
{
var jidRule = rule as JidPrivacyRule;
if (jidRule.Jid == jid && jidRule.Allow == false)
set.Add(jidRule);
}
}
foreach (var rule in set)
privacyList.Remove(rule);
// Save the privacy list and activate it.
if (privacyList.Count == 0)
{
im.SetDefaultPrivacyList();
im.RemovePrivacyList(privacyList.Name);
}
else
{
im.EditPrivacyList(privacyList);
im.SetDefaultPrivacyList(privacyList.Name);
}
}
}
示例14: Block
/// <summary>
/// Blocks all communication to and from the XMPP entity with the specified JID.
/// </summary>
/// <param name="jid">The JID of the XMPP entity to block.</param>
/// <exception cref="ArgumentNullException">The jid parameter is
/// null.</exception>
/// <exception cref="NotSupportedException">The server does not support the
/// 'Blocking Command' extension and does not support privacy-list management.
/// </exception>
/// <exception cref="XmppErrorException">The server returned an XMPP error code.
/// Use the Error property of the XmppErrorException to obtain the specific
/// error condition.</exception>
/// <exception cref="XmppException">The server returned invalid data or another
/// unspecified XMPP error occurred.</exception>
/// <exception cref="InvalidOperationException">The XmppClient instance is
/// not connected to a remote host.</exception>
/// <exception cref="ObjectDisposedException">The XmppClient object
/// has been disposed.</exception>
public void Block(Jid jid)
{
AssertValid();
jid.ThrowIfNull("jid");
// If our server supports the 'Blocking Command' extension, we can just
// use that.
if (block.Supported)
block.Block(jid);
else
{
// Privacy list blocking. If our server doesn't support privacy lists, we're
// out of luck.
PrivacyList privacyList = null;
string name = im.GetDefaultPrivacyList();
if (name != null)
privacyList = im.GetPrivacyList(name);
// If no default list has been set, look for a 'blocklist' list.
foreach (var list in im.GetPrivacyLists())
{
if (list.Name == "blocklist")
privacyList = list;
}
// If 'blocklist' doesn't exist, create it and set it as default.
if (privacyList == null)
privacyList = new PrivacyList("blocklist");
privacyList.Add(new JidPrivacyRule(jid, false, 0), true);
// Save the privacy list and activate it.
im.EditPrivacyList(privacyList);
im.SetDefaultPrivacyList(privacyList.Name);
im.SetActivePrivacyList(privacyList.Name);
}
}
示例15: CancelFileTransfer
/// <summary>
/// Cancels the specified file-transfer.
/// </summary>
/// <param name="from">From Jid</param>
/// <param name="sid">Sid</param>
/// <param name="to">To Jid</param>
/// <exception cref="ArgumentNullException">The transfer parameter is
/// null.</exception>
/// <exception cref="ArgumentException">The specified transfer instance does
/// not represent an active data-transfer operation.</exception>
/// <exception cref="InvalidOperationException">The XmppClient instance is not
/// connected to a remote host, or the XmppClient instance has not authenticated with
/// the XMPP server.</exception>
/// <exception cref="ObjectDisposedException">The XmppClient object has been
/// disposed.</exception>
public void CancelFileTransfer(string sid, Jid from, Jid to)
{
#if DEBUG
System.Diagnostics.Debug.WriteLine("XmppClient CancelFileTransfer, sid {0}, from {1}, to {2}", sid, from.ToString(), to.ToString());
#endif
AssertValid();
sid.ThrowIfNullOrEmpty("sid");
from.ThrowIfNull("from");
to.ThrowIfNull("to");
siFileTransfer.CancelFileTransfer(sid, from, to);
}