本文整理汇总了C#中Maybe.DefaultIfEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# Maybe.DefaultIfEmpty方法的具体用法?C# Maybe.DefaultIfEmpty怎么用?C# Maybe.DefaultIfEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maybe
的用法示例。
在下文中一共展示了Maybe.DefaultIfEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Join
public Join(string server, Prefix prefix, IImmutableList<string> channels, Maybe<IImmutableList<string>> keys)
{
if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("Null or whitespace string", "server");
if (prefix == null) throw new ArgumentNullException("prefix");
if (channels == null) throw new ArgumentNullException("channels");
if (channels.Count == 0 || channels.Any(c => String.IsNullOrWhiteSpace(c))) throw new ArgumentException("Empty channel list or list contains an empty element.", "channels");
if (keys.HasValue && keys.Value.Count != 0 && (keys.Value.Count != channels.Count || keys.Value.Any(k => String.IsNullOrWhiteSpace(k)))) throw new ArgumentException("Non-empty key list contains an empty element or doesn't have the same number of elements as the channel list.", "keys");
this.server = server;
this.prefix = prefix;
this.channels = channels;
this.keys = keys.DefaultIfEmpty(ImmutableList<string>.Empty).Single();
this.ircMessage = Common.CreateIrcMessageFormat(prefix, Join.CanonicalCommand, "{0} {1}", String.Join(",", this.Channels), String.Join(",", this.Keys));
}
示例2: Quit
public Quit(string server, Prefix prefix, Maybe<string> message)
{
if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("Null or whitespace string", "server");
if (prefix == null) throw new ArgumentNullException("prefix");
this.server = server;
this.prefix = prefix;
this.message = message.DefaultIfEmpty(String.Empty).Single();
if (this.Message != String.Empty)
{
this.ircMessage = Common.CreateIrcMessageFormat(this.Prefix, Quit.CanonicalCommand, ":{0}", this.Message);
}
else
{
this.ircMessage = Common.CreateIrcMessageFormat(this.Prefix, Quit.CanonicalCommand, "");
}
}
示例3: Kick
public Kick(string server, Prefix prefix, string channel, string nick, Maybe<string> reason)
{
if (String.IsNullOrWhiteSpace(server)) throw new ArgumentException("Null or whitespace string", "server");
if (prefix == null) throw new ArgumentNullException("prefix");
if (String.IsNullOrWhiteSpace(channel)) throw new ArgumentException("Null or whitespace string", "channel");
this.server = server;
this.prefix = prefix;
this.channel = channel;
this.nick = nick;
this.reason = reason.DefaultIfEmpty(String.Empty).Single();
if (this.Reason != String.Empty)
{
this.ircMessage = Common.CreateIrcMessageFormat(this.Prefix, Kick.CanonicalCommand, "{0} {1} :{2}", this.Channel, this.Nick, this.Reason);
}
else
{
this.ircMessage = Common.CreateIrcMessageFormat(this.Prefix, Kick.CanonicalCommand, "{0} {1}", this.Channel, this.Nick);
}
}