Пример #1
0
            /// <summary>
            /// TBD
            /// </summary>
            /// <param name="that">TBD</param>
            /// <exception cref="InvalidOperationException">
            /// This exception is thrown if this <see cref="ByteString"/> cannot be concatenated with <paramref name="that"/>.
            /// </exception>
            /// <returns>TBD</returns>
            public override ByteString Concat(ByteString that)
            {
                if (that.IsEmpty)
                {
                    return(this);
                }
                else if (this.IsEmpty)
                {
                    return(that);
                }
                else
                {
                    var b1c = that as ByteString1C;
                    if (b1c != null)
                    {
                        return(new ByteStrings(Items.Concat(b1c.ToByteString1()).ToArray()));
                    }

                    var b1 = that as ByteString1;
                    if (b1 != null)
                    {
                        return(new ByteStrings(Items.Concat(b1).ToArray()));
                    }

                    var bs = that as ByteStrings;
                    if (bs != null)
                    {
                        return(new ByteStrings(Items.Concat(bs.Items).ToArray()));
                    }

                    throw new InvalidOperationException($"No suitable implementation found for concatenating ByteString of type {that.GetType()}");
                }
            }
Пример #2
0
            /// <summary></summary>
            /// <exception cref="InvalidOperationException">
            /// This exception is thrown if this <see cref="ByteString"/> cannot be concatenated with <paramref name="that"/>.
            /// </exception>
            public override ByteString Concat(ByteString that)
            {
                if (that.IsEmpty)
                {
                    return this;
                }
                else if (this.IsEmpty)
                {
                    return that;
                }
                else
                {
                    var b1c = that as ByteString1C;
                    if (b1c != null)
                    {
                        return new ByteStrings(Items.Concat(b1c.ToByteString1()).ToArray());
                    }

                    var b1 = that as ByteString1;
                    if (b1 != null)
                    {
                        return new ByteStrings(Items.Concat(b1).ToArray());
                    }

                    var bs = that as ByteStrings;
                    if (bs != null)
                    {
                        return new ByteStrings(Items.Concat(bs.Items).ToArray());
                    }

                    throw new InvalidOperationException($"No suitable implementation found for concatenating ByteString of type {that.GetType()}");
                }
            }