当前位置: 首页>>代码示例>>C#>>正文


C# Maybe.DefaultIfEmpty方法代码示例

本文整理汇总了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));
        }
开发者ID:nehresmann,项目名称:Nyaxix.Irc,代码行数:14,代码来源:Join.cs

示例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, "");
            }
        }
开发者ID:nehresmann,项目名称:Nyaxix.Irc,代码行数:18,代码来源:Quit.cs

示例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);
            }
        }
开发者ID:nehresmann,项目名称:Nyaxix.Irc,代码行数:21,代码来源:Kick.cs


注:本文中的Maybe.DefaultIfEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。