ProtoBuf 简单测试


// csc test.cs /r:Google.ProtocolBuffers.dll
namespace ConsoleApplication
{
    using System;
    using System.IO;
    using System.Linq;
    using Google.ProtocolBuffers;
    using Microshaoft;
    /// <summary>
    /// Class1 的摘要说明。
    /// </summary>
    public class Program
    {
        static void Main(string[] args)
        {
            int iterations = 10000;
            CodeTimer.Time
                        (
                            "ProtoBuf 串行测试",
                            iterations,
                            () =>
                            {
                                Test();
                            }
                        );
            CodeTimer.ParallelTime
                        (
                            "ProtoBuf 并行测试",
                            iterations,
                            () =>
                            {
                                Test();
                            }
                        );
            Console.WriteLine();
            Console.WriteLine("Hello World");
            Console.WriteLine(Environment.Version.ToString());
            Console.ReadLine();
        }
        //[STAThread]
        static void Test()
        {
            pbMessage.Builder msg = pbMessage.CreateBuilder();
            msg.SetSenderID("SenderID");
            byte[] buffer = new byte[10];
            ByteString bs = ByteString.CopyFrom(buffer);
            msg.SetSignature(bs);
            msg.SetTimeStamp("2012-03-22 00:00:00");
            pbMessageHeader.Builder header = pbMessageHeader.CreateBuilder();
            header.SetMessageID(10001);
            header.SetMessageName("MessageName");
            MemoryStream stream;
            stream = new MemoryStream();
            header.Build().WriteTo(stream);
            buffer = StreamDataHelper.ReadDataToBytes(stream);
            bs = ByteString.CopyFrom(buffer);
            msg.SetHeaderData(bs);
            pbMessageBody.Builder body = pbMessageBody.CreateBuilder();
            body.SetF1("body F1");
            body.SetF2(-1);
            ComplexType.Builder ct = ComplexType.CreateBuilder();
            ct.SetFF1("FF1-1");
            ct.SetFF2(-7);
            body.AddF3(ct);
            ct.SetFF1("FF1-2");
            ct.SetFF2(-8);
            body.AddF3(ct);
            stream = new MemoryStream();
            body.Build().WriteTo(stream);
            buffer = StreamDataHelper.ReadDataToBytes(stream);
            bs = ByteString.CopyFrom(buffer);
            msg.SetBodyData(bs);
            stream = new MemoryStream();
            msg.Build().WriteTo(stream);
            buffer = StreamDataHelper.ReadDataToBytes(stream);
///            Console.WriteLine("protoBuf 序列化 byte[].Length: {0}", buffer.Length);
///            //============================================
///            Console.WriteLine("protoBuf 反序列化...");
            pbMessage.Builder msg1 = pbMessage.CreateBuilder();
            msg1.MergeFrom(buffer);
///            Console.WriteLine(msg1.SenderID);
            pbMessageHeader.Builder header1 = pbMessageHeader.CreateBuilder();
            header1.MergeFrom(msg1.HeaderData);
///            Console.WriteLine(header1.MessageName);
            pbMessageBody.Builder body1 = pbMessageBody.CreateBuilder();
            body1.MergeFrom(msg1.BodyData);
///            Console.WriteLine(body1.F1);
///            Console.WriteLine(body1.F2);
///            body1.F3List.ToList().ForEach
///                                    (
///                                        (entry) =>
///                                        {
///                                            Console.WriteLine("{0},{1}", entry.FF1, entry.FF2);
///                                        }
///                                    );
            Print(msg1, header1, body1);
        }
        static void Print(pbMessage.Builder x, pbMessageHeader.Builder y, pbMessageBody.Builder z)
        {
            return;
            Console.WriteLine(x.SenderID);
            Console.WriteLine(y.MessageName);
            Console.WriteLine(z.F1);
            Console.WriteLine(z.F2);
            z.F3List.ToList().ForEach
                                    (
                                        (entry) =>
                                        {
                                            Console.WriteLine("{0},{1}", entry.FF1, entry.FF2);
                                        }
                                    );
        }
    }
}
namespace Microshaoft
{
    using System;
    using System.Diagnostics;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Runtime.InteropServices;
    public static class CodeTimer
    {
        public static void Initialize()
        {
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
            Time("", 1, () => { });
        }
        public static void ParallelTime(string name, int iteration, Action action)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            // 1.
            ConsoleColor currentForeColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(name);
            // 2.
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            int[] gcCounts = new int[GC.MaxGeneration + 1];
            for (int i = 0; i <= GC.MaxGeneration; i++)
            {
                gcCounts[i] = GC.CollectionCount(i);
            }
            // 3.
            Stopwatch watch = new Stopwatch();
            watch.Start();
            ulong cycleCount = GetCycleCount();
            Parallel.For
                (
                    0
                    , iteration
                    , i =>
                    {
                        action();
                    }
                );
            ulong cpuCycles = GetCycleCount() - cycleCount;
            watch.Stop();
            // 4.
            Console.ForegroundColor = currentForeColor;
            Console.WriteLine("\tTime Elapsed:\t" + watch.ElapsedMilliseconds.ToString("N0") + "ms");
            Console.WriteLine("\tCPU Cycles:\t" + cpuCycles.ToString("N0"));
            // 5.
            for (int i = 0; i <= GC.MaxGeneration; i++)
            {
                int count = GC.CollectionCount(i) - gcCounts[i];
                Console.WriteLine("\tGen " + i + ": \t\t" + count);
            }
            Console.WriteLine();
        }
        public static void Time(string name, int iteration, Action action)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            // 1.
            ConsoleColor currentForeColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(name);
            // 2.
            GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
            int[] gcCounts = new int[GC.MaxGeneration + 1];
            for (int i = 0; i <= GC.MaxGeneration; i++)
            {
                gcCounts[i] = GC.CollectionCount(i);
            }
            // 3.
            Stopwatch watch = new Stopwatch();
            watch.Start();
            ulong cycleCount = GetCycleCount();
            for (int i = 0; i < iteration; i++)
            {
                action();
            }
            ulong cpuCycles = GetCycleCount() - cycleCount;
            watch.Stop();
            // 4.
            Console.ForegroundColor = currentForeColor;
            Console.WriteLine("\tTime Elapsed:\t" + watch.ElapsedMilliseconds.ToString("N0") + "ms");
            Console.WriteLine("\tCPU Cycles:\t" + cpuCycles.ToString("N0"));
            // 5.
            for (int i = 0; i <= GC.MaxGeneration; i++)
            {
                int count = GC.CollectionCount(i) - gcCounts[i];
                Console.WriteLine("\tGen " + i + ": \t\t" + count);
            }
            Console.WriteLine();
        }
        private static ulong GetCycleCount()
        {
            ulong cycleCount = 0;
            QueryThreadCycleTime(GetCurrentThread(), ref cycleCount);
            return cycleCount;
        }
        [DllImport("kernel32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool QueryThreadCycleTime(IntPtr threadHandle, ref ulong cycleTime);
        [DllImport("kernel32.dll")]
        static extern IntPtr GetCurrentThread();
    }
}
namespace Microshaoft
{
    using System.IO;
    public static class StreamDataHelper
    {
        public static byte[] ReadDataToBytes(Stream stream)
        {
            byte[] buffer = new byte[64 * 1024];
            MemoryStream ms = new MemoryStream();
            int r = 0;
            int l = 0;
            long position = -1;
            if (stream.CanSeek)
            {
                position = stream.Position;
                stream.Position = 0;
            }
            while (true)
            {
                r = stream.Read(buffer, 0, buffer.Length);
                if (r > 0)
                {
                    l += r;
                    ms.Write(buffer, 0, r);
                }
                else
                {
                    break;
                }
            }
            byte[] bytes = new byte[l];
            ms.Position = 0;
            ms.Read(bytes, 0, (int)l);
            ms.Close();
            ms.Dispose();
            ms = null;
            if (position >= 0)
            {
                stream.Position = position;
            }
            return bytes;
        }
    }
}
/*
// protoc.exe --descriptor_set_out=..\test.pb --proto_path=..\ --include_imports ..\test.proto
// ProtoGen.exe ..\test.pb -output_directory=..\
package Microshaoft;
option optimize_for = SPEED;
message pbMessage
{
    required string SenderID = 1;
    required string TimeStamp = 2;        // Unique ID number for this person.
    required bytes Signature = 3;
    required bytes HeaderData =4;
    optional bytes BodyData = 5;
}
message pbMessageHeader
{
     required string MessageName = 1;
     required int32 MessageID = 2;
}
message pbMessageBody
{
     required string F1 = 1;
     required int32 F2 = 2;
     repeated ComplexType F3 = 3;
}
message ComplexType
{
     required string FF1 = 1;
     required int32 FF2 = 2;
}
*/
// /r: cmd\Google.ProtocolBuffers.dll
// Generated by ProtoGen, Version=2.3.0.277, Culture=neutral, PublicKeyToken=17b3b1f090c3ea48.  DO NOT EDIT!
// Generated by ProtoGen, Version=2.3.0.277, Culture=neutral, PublicKeyToken=17b3b1f090c3ea48.  DO NOT EDIT!
#pragma warning disable 1591, 0612
#region Designer generated code
namespace Microshaoft
{
    using pb = global::Google.ProtocolBuffers;
    using pbc = global::Google.ProtocolBuffers.Collections;
    using pbd = global::Google.ProtocolBuffers.Descriptors;
    using scg = global::System.Collections.Generic;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
    public static partial class Test
    {
        #region Extension registration
        public static void RegisterAllExtensions(pb::ExtensionRegistry registry)
        {
        }
        #endregion
        #region Static variables
        internal static pbd::MessageDescriptor internal__static_Microshaoft_pbMessage__Descriptor;
        internal static pb::FieldAccess.FieldAccessorTable<global::Microshaoft.pbMessage, global::Microshaoft.pbMessage.Builder> internal__static_Microshaoft_pbMessage__FieldAccessorTable;
        internal static pbd::MessageDescriptor internal__static_Microshaoft_pbMessageHeader__Descriptor;
        internal static pb::FieldAccess.FieldAccessorTable<global::Microshaoft.pbMessageHeader, global::Microshaoft.pbMessageHeader.Builder> internal__static_Microshaoft_pbMessageHeader__FieldAccessorTable;
        internal static pbd::MessageDescriptor internal__static_Microshaoft_pbMessageBody__Descriptor;
        internal static pb::FieldAccess.FieldAccessorTable<global::Microshaoft.pbMessageBody, global::Microshaoft.pbMessageBody.Builder> internal__static_Microshaoft_pbMessageBody__FieldAccessorTable;
        internal static pbd::MessageDescriptor internal__static_Microshaoft_ComplexType__Descriptor;
        internal static pb::FieldAccess.FieldAccessorTable<global::Microshaoft.ComplexType, global::Microshaoft.ComplexType.Builder> internal__static_Microshaoft_ComplexType__FieldAccessorTable;
        #endregion
        #region Descriptor
        public static pbd::FileDescriptor Descriptor
        {
            get { return descriptor; }
        }
        private static pbd::FileDescriptor descriptor;
        static Test()
        {
            byte[] descriptorData = global::System.Convert.FromBase64String(
                "Cgp0ZXN0LnByb3RvEgtNaWNyb3NoYW9mdCJpCglwYk1lc3NhZ2USEAoIU2Vu" +
                "ZGVySUQYASACKAkSEQoJVGltZVN0YW1wGAIgAigJEhEKCVNpZ25hdHVyZRgD" +
                "IAIoDBISCgpIZWFkZXJEYXRhGAQgAigMEhAKCEJvZHlEYXRhGAUgASgMIjkK" +
                "D3BiTWVzc2FnZUhlYWRlchITCgtNZXNzYWdlTmFtZRgBIAIoCRIRCglNZXNz" +
                "YWdlSUQYAiACKAUiTQoNcGJNZXNzYWdlQm9keRIKCgJGMRgBIAIoCRIKCgJG" +
                "MhgCIAIoBRIkCgJGMxgDIAMoCzIYLk1pY3Jvc2hhb2Z0LkNvbXBsZXhUeXBl" +
                "IicKC0NvbXBsZXhUeXBlEgsKA0ZGMRgBIAIoCRILCgNGRjIYAiACKAVCAkgB");
            pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root)
            {
                descriptor = root;
                internal__static_Microshaoft_pbMessage__Descriptor = Descriptor.MessageTypes[0];
                internal__static_Microshaoft_pbMessage__FieldAccessorTable =
                    new pb::FieldAccess.FieldAccessorTable<global::Microshaoft.pbMessage, global::Microshaoft.pbMessage.Builder>(internal__static_Microshaoft_pbMessage__Descriptor,
                        new string[] { "SenderID", "TimeStamp", "Signature", "HeaderData", "BodyData", });
                internal__static_Microshaoft_pbMessageHeader__Descriptor = Descriptor.MessageTypes[1];
                internal__static_Microshaoft_pbMessageHeader__FieldAccessorTable =
                    new pb::FieldAccess.FieldAccessorTable<global::Microshaoft.pbMessageHeader, global::Microshaoft.pbMessageHeader.Builder>(internal__static_Microshaoft_pbMessageHeader__Descriptor,
                        new string[] { "MessageName", "MessageID", });
                internal__static_Microshaoft_pbMessageBody__Descriptor = Descriptor.MessageTypes[2];
                internal__static_Microshaoft_pbMessageBody__FieldAccessorTable =
                    new pb::FieldAccess.FieldAccessorTable<global::Microshaoft.pbMessageBody, global::Microshaoft.pbMessageBody.Builder>(internal__static_Microshaoft_pbMessageBody__Descriptor,
                        new string[] { "F1", "F2", "F3", });
                internal__static_Microshaoft_ComplexType__Descriptor = Descriptor.MessageTypes[3];
                internal__static_Microshaoft_ComplexType__FieldAccessorTable =
                    new pb::FieldAccess.FieldAccessorTable<global::Microshaoft.ComplexType, global::Microshaoft.ComplexType.Builder>(internal__static_Microshaoft_ComplexType__Descriptor,
                        new string[] { "FF1", "FF2", });
                return null;
            };
            pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
                new pbd::FileDescriptor[] {
          }, assigner);
        }
        #endregion
    }
    #region Messages
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
    public sealed partial class pbMessage : pb::GeneratedMessage<pbMessage, pbMessage.Builder>
    {
        private pbMessage() { }
        private static readonly pbMessage defaultInstance = new pbMessage().MakeReadOnly();
        private static readonly string[] _pbMessageFieldNames = new string[] { "BodyData", "HeaderData", "SenderID", "Signature", "TimeStamp" };
        private static readonly uint[] _pbMessageFieldTags = new uint[] { 42, 34, 10, 26, 18 };
        public static pbMessage DefaultInstance
        {
            get { return defaultInstance; }
        }
        public override pbMessage DefaultInstanceForType
        {
            get { return DefaultInstance; }
        }
        protected override pbMessage ThisMessage
        {
            get { return this; }
        }
        public static pbd::MessageDescriptor Descriptor
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_pbMessage__Descriptor; }
        }
        protected override pb::FieldAccess.FieldAccessorTable<pbMessage, pbMessage.Builder> InternalFieldAccessors
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_pbMessage__FieldAccessorTable; }
        }
        public const int SenderIDFieldNumber = 1;
        private bool hasSenderID;
        private string senderID_ = "";
        public bool HasSenderID
        {
            get { return hasSenderID; }
        }
        public string SenderID
        {
            get { return senderID_; }
        }
        public const int TimeStampFieldNumber = 2;
        private bool hasTimeStamp;
        private string timeStamp_ = "";
        public bool HasTimeStamp
        {
            get { return hasTimeStamp; }
        }
        public string TimeStamp
        {
            get { return timeStamp_; }
        }
        public const int SignatureFieldNumber = 3;
        private bool hasSignature;
        private pb::ByteString signature_ = pb::ByteString.Empty;
        public bool HasSignature
        {
            get { return hasSignature; }
        }
        public pb::ByteString Signature
        {
            get { return signature_; }
        }
        public const int HeaderDataFieldNumber = 4;
        private bool hasHeaderData;
        private pb::ByteString headerData_ = pb::ByteString.Empty;
        public bool HasHeaderData
        {
            get { return hasHeaderData; }
        }
        public pb::ByteString HeaderData
        {
            get { return headerData_; }
        }
        public const int BodyDataFieldNumber = 5;
        private bool hasBodyData;
        private pb::ByteString bodyData_ = pb::ByteString.Empty;
        public bool HasBodyData
        {
            get { return hasBodyData; }
        }
        public pb::ByteString BodyData
        {
            get { return bodyData_; }
        }
        public override bool IsInitialized
        {
            get
            {
                if (!hasSenderID) return false;
                if (!hasTimeStamp) return false;
                if (!hasSignature) return false;
                if (!hasHeaderData) return false;
                return true;
            }
        }
        public override void WriteTo(pb::ICodedOutputStream output)
        {
            int size = SerializedSize;
            string[] field_names = _pbMessageFieldNames;
            if (hasSenderID)
            {
                output.WriteString(1, field_names[2], SenderID);
            }
            if (hasTimeStamp)
            {
                output.WriteString(2, field_names[4], TimeStamp);
            }
            if (hasSignature)
            {
                output.WriteBytes(3, field_names[3], Signature);
            }
            if (hasHeaderData)
            {
                output.WriteBytes(4, field_names[1], HeaderData);
            }
            if (hasBodyData)
            {
                output.WriteBytes(5, field_names[0], BodyData);
            }
            UnknownFields.WriteTo(output);
        }
        private int memoizedSerializedSize = -1;
        public override int SerializedSize
        {
            get
            {
                int size = memoizedSerializedSize;
                if (size != -1) return size;
                size = 0;
                if (hasSenderID)
                {
                    size += pb::CodedOutputStream.ComputeStringSize(1, SenderID);
                }
                if (hasTimeStamp)
                {
                    size += pb::CodedOutputStream.ComputeStringSize(2, TimeStamp);
                }
                if (hasSignature)
                {
                    size += pb::CodedOutputStream.ComputeBytesSize(3, Signature);
                }
                if (hasHeaderData)
                {
                    size += pb::CodedOutputStream.ComputeBytesSize(4, HeaderData);
                }
                if (hasBodyData)
                {
                    size += pb::CodedOutputStream.ComputeBytesSize(5, BodyData);
                }
                size += UnknownFields.SerializedSize;
                memoizedSerializedSize = size;
                return size;
            }
        }
        public static pbMessage ParseFrom(pb::ByteString data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static pbMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static pbMessage ParseFrom(byte[] data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static pbMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static pbMessage ParseFrom(global::System.IO.Stream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static pbMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        public static pbMessage ParseDelimitedFrom(global::System.IO.Stream input)
        {
            return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
        }
        public static pbMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
        }
        public static pbMessage ParseFrom(pb::ICodedInputStream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static pbMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        private pbMessage MakeReadOnly()
        {
            return this;
        }
        public static Builder CreateBuilder() { return new Builder(); }
        public override Builder ToBuilder() { return CreateBuilder(this); }
        public override Builder CreateBuilderForType() { return new Builder(); }
        public static Builder CreateBuilder(pbMessage prototype)
        {
            return new Builder(prototype);
        }
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
        public sealed partial class Builder : pb::GeneratedBuilder<pbMessage, Builder>
        {
            protected override Builder ThisBuilder
            {
                get { return this; }
            }
            public Builder()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
            }
            internal Builder(pbMessage cloneFrom)
            {
                result = cloneFrom;
                resultIsReadOnly = true;
            }
            private bool resultIsReadOnly;
            private pbMessage result;
            private pbMessage PrepareBuilder()
            {
                if (resultIsReadOnly)
                {
                    pbMessage original = result;
                    result = new pbMessage();
                    resultIsReadOnly = false;
                    MergeFrom(original);
                }
                return result;
            }
            public override bool IsInitialized
            {
                get { return result.IsInitialized; }
            }
            protected override pbMessage MessageBeingBuilt
            {
                get { return PrepareBuilder(); }
            }
            public override Builder Clear()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
                return this;
            }
            public override Builder Clone()
            {
                if (resultIsReadOnly)
                {
                    return new Builder(result);
                }
                else
                {
                    return new Builder().MergeFrom(result);
                }
            }
            public override pbd::MessageDescriptor DescriptorForType
            {
                get { return global::Microshaoft.pbMessage.Descriptor; }
            }
            public override pbMessage DefaultInstanceForType
            {
                get { return global::Microshaoft.pbMessage.DefaultInstance; }
            }
            public override pbMessage BuildPartial()
            {
                if (resultIsReadOnly)
                {
                    return result;
                }
                resultIsReadOnly = true;
                return result.MakeReadOnly();
            }
            public override Builder MergeFrom(pb::IMessage other)
            {
                if (other is pbMessage)
                {
                    return MergeFrom((pbMessage)other);
                }
                else
                {
                    base.MergeFrom(other);
                    return this;
                }
            }
            public override Builder MergeFrom(pbMessage other)
            {
                if (other == global::Microshaoft.pbMessage.DefaultInstance) return this;
                PrepareBuilder();
                if (other.HasSenderID)
                {
                    SenderID = other.SenderID;
                }
                if (other.HasTimeStamp)
                {
                    TimeStamp = other.TimeStamp;
                }
                if (other.HasSignature)
                {
                    Signature = other.Signature;
                }
                if (other.HasHeaderData)
                {
                    HeaderData = other.HeaderData;
                }
                if (other.HasBodyData)
                {
                    BodyData = other.BodyData;
                }
                this.MergeUnknownFields(other.UnknownFields);
                return this;
            }
            public override Builder MergeFrom(pb::ICodedInputStream input)
            {
                return MergeFrom(input, pb::ExtensionRegistry.Empty);
            }
            public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
            {
                PrepareBuilder();
                pb::UnknownFieldSet.Builder unknownFields = null;
                uint tag;
                string field_name;
                while (input.ReadTag(out tag, out field_name))
                {
                    if (tag == 0 && field_name != null)
                    {
                        int field_ordinal = global::System.Array.BinarySearch(_pbMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
                        if (field_ordinal >= 0)
                            tag = _pbMessageFieldTags[field_ordinal];
                        else
                        {
                            if (unknownFields == null)
                            {
                                unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                            }
                            ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                            continue;
                        }
                    }
                    switch (tag)
                    {
                        case 0:
                            {
                                throw pb::InvalidProtocolBufferException.InvalidTag();
                            }
                        default:
                            {
                                if (pb::WireFormat.IsEndGroupTag(tag))
                                {
                                    if (unknownFields != null)
                                    {
                                        this.UnknownFields = unknownFields.Build();
                                    }
                                    return this;
                                }
                                if (unknownFields == null)
                                {
                                    unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                                }
                                ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                                break;
                            }
                        case 10:
                            {
                                result.hasSenderID = input.ReadString(ref result.senderID_);
                                break;
                            }
                        case 18:
                            {
                                result.hasTimeStamp = input.ReadString(ref result.timeStamp_);
                                break;
                            }
                        case 26:
                            {
                                result.hasSignature = input.ReadBytes(ref result.signature_);
                                break;
                            }
                        case 34:
                            {
                                result.hasHeaderData = input.ReadBytes(ref result.headerData_);
                                break;
                            }
                        case 42:
                            {
                                result.hasBodyData = input.ReadBytes(ref result.bodyData_);
                                break;
                            }
                    }
                }
                if (unknownFields != null)
                {
                    this.UnknownFields = unknownFields.Build();
                }
                return this;
            }
            public bool HasSenderID
            {
                get { return result.hasSenderID; }
            }
            public string SenderID
            {
                get { return result.SenderID; }
                set { SetSenderID(value); }
            }
            public Builder SetSenderID(string value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasSenderID = true;
                result.senderID_ = value;
                return this;
            }
            public Builder ClearSenderID()
            {
                PrepareBuilder();
                result.hasSenderID = false;
                result.senderID_ = "";
                return this;
            }
            public bool HasTimeStamp
            {
                get { return result.hasTimeStamp; }
            }
            public string TimeStamp
            {
                get { return result.TimeStamp; }
                set { SetTimeStamp(value); }
            }
            public Builder SetTimeStamp(string value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasTimeStamp = true;
                result.timeStamp_ = value;
                return this;
            }
            public Builder ClearTimeStamp()
            {
                PrepareBuilder();
                result.hasTimeStamp = false;
                result.timeStamp_ = "";
                return this;
            }
            public bool HasSignature
            {
                get { return result.hasSignature; }
            }
            public pb::ByteString Signature
            {
                get { return result.Signature; }
                set { SetSignature(value); }
            }
            public Builder SetSignature(pb::ByteString value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasSignature = true;
                result.signature_ = value;
                return this;
            }
            public Builder ClearSignature()
            {
                PrepareBuilder();
                result.hasSignature = false;
                result.signature_ = pb::ByteString.Empty;
                return this;
            }
            public bool HasHeaderData
            {
                get { return result.hasHeaderData; }
            }
            public pb::ByteString HeaderData
            {
                get { return result.HeaderData; }
                set { SetHeaderData(value); }
            }
            public Builder SetHeaderData(pb::ByteString value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasHeaderData = true;
                result.headerData_ = value;
                return this;
            }
            public Builder ClearHeaderData()
            {
                PrepareBuilder();
                result.hasHeaderData = false;
                result.headerData_ = pb::ByteString.Empty;
                return this;
            }
            public bool HasBodyData
            {
                get { return result.hasBodyData; }
            }
            public pb::ByteString BodyData
            {
                get { return result.BodyData; }
                set { SetBodyData(value); }
            }
            public Builder SetBodyData(pb::ByteString value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasBodyData = true;
                result.bodyData_ = value;
                return this;
            }
            public Builder ClearBodyData()
            {
                PrepareBuilder();
                result.hasBodyData = false;
                result.bodyData_ = pb::ByteString.Empty;
                return this;
            }
        }
        static pbMessage()
        {
            object.ReferenceEquals(global::Microshaoft.Test.Descriptor, null);
        }
    }
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
    public sealed partial class pbMessageHeader : pb::GeneratedMessage<pbMessageHeader, pbMessageHeader.Builder>
    {
        private pbMessageHeader() { }
        private static readonly pbMessageHeader defaultInstance = new pbMessageHeader().MakeReadOnly();
        private static readonly string[] _pbMessageHeaderFieldNames = new string[] { "MessageID", "MessageName" };
        private static readonly uint[] _pbMessageHeaderFieldTags = new uint[] { 16, 10 };
        public static pbMessageHeader DefaultInstance
        {
            get { return defaultInstance; }
        }
        public override pbMessageHeader DefaultInstanceForType
        {
            get { return DefaultInstance; }
        }
        protected override pbMessageHeader ThisMessage
        {
            get { return this; }
        }
        public static pbd::MessageDescriptor Descriptor
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_pbMessageHeader__Descriptor; }
        }
        protected override pb::FieldAccess.FieldAccessorTable<pbMessageHeader, pbMessageHeader.Builder> InternalFieldAccessors
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_pbMessageHeader__FieldAccessorTable; }
        }
        public const int MessageNameFieldNumber = 1;
        private bool hasMessageName;
        private string messageName_ = "";
        public bool HasMessageName
        {
            get { return hasMessageName; }
        }
        public string MessageName
        {
            get { return messageName_; }
        }
        public const int MessageIDFieldNumber = 2;
        private bool hasMessageID;
        private int messageID_;
        public bool HasMessageID
        {
            get { return hasMessageID; }
        }
        public int MessageID
        {
            get { return messageID_; }
        }
        public override bool IsInitialized
        {
            get
            {
                if (!hasMessageName) return false;
                if (!hasMessageID) return false;
                return true;
            }
        }
        public override void WriteTo(pb::ICodedOutputStream output)
        {
            int size = SerializedSize;
            string[] field_names = _pbMessageHeaderFieldNames;
            if (hasMessageName)
            {
                output.WriteString(1, field_names[1], MessageName);
            }
            if (hasMessageID)
            {
                output.WriteInt32(2, field_names[0], MessageID);
            }
            UnknownFields.WriteTo(output);
        }
        private int memoizedSerializedSize = -1;
        public override int SerializedSize
        {
            get
            {
                int size = memoizedSerializedSize;
                if (size != -1) return size;
                size = 0;
                if (hasMessageName)
                {
                    size += pb::CodedOutputStream.ComputeStringSize(1, MessageName);
                }
                if (hasMessageID)
                {
                    size += pb::CodedOutputStream.ComputeInt32Size(2, MessageID);
                }
                size += UnknownFields.SerializedSize;
                memoizedSerializedSize = size;
                return size;
            }
        }
        public static pbMessageHeader ParseFrom(pb::ByteString data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(byte[] data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(global::System.IO.Stream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        public static pbMessageHeader ParseDelimitedFrom(global::System.IO.Stream input)
        {
            return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
        }
        public static pbMessageHeader ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(pb::ICodedInputStream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static pbMessageHeader ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        private pbMessageHeader MakeReadOnly()
        {
            return this;
        }
        public static Builder CreateBuilder() { return new Builder(); }
        public override Builder ToBuilder() { return CreateBuilder(this); }
        public override Builder CreateBuilderForType() { return new Builder(); }
        public static Builder CreateBuilder(pbMessageHeader prototype)
        {
            return new Builder(prototype);
        }
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
        public sealed partial class Builder : pb::GeneratedBuilder<pbMessageHeader, Builder>
        {
            protected override Builder ThisBuilder
            {
                get { return this; }
            }
            public Builder()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
            }
            internal Builder(pbMessageHeader cloneFrom)
            {
                result = cloneFrom;
                resultIsReadOnly = true;
            }
            private bool resultIsReadOnly;
            private pbMessageHeader result;
            private pbMessageHeader PrepareBuilder()
            {
                if (resultIsReadOnly)
                {
                    pbMessageHeader original = result;
                    result = new pbMessageHeader();
                    resultIsReadOnly = false;
                    MergeFrom(original);
                }
                return result;
            }
            public override bool IsInitialized
            {
                get { return result.IsInitialized; }
            }
            protected override pbMessageHeader MessageBeingBuilt
            {
                get { return PrepareBuilder(); }
            }
            public override Builder Clear()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
                return this;
            }
            public override Builder Clone()
            {
                if (resultIsReadOnly)
                {
                    return new Builder(result);
                }
                else
                {
                    return new Builder().MergeFrom(result);
                }
            }
            public override pbd::MessageDescriptor DescriptorForType
            {
                get { return global::Microshaoft.pbMessageHeader.Descriptor; }
            }
            public override pbMessageHeader DefaultInstanceForType
            {
                get { return global::Microshaoft.pbMessageHeader.DefaultInstance; }
            }
            public override pbMessageHeader BuildPartial()
            {
                if (resultIsReadOnly)
                {
                    return result;
                }
                resultIsReadOnly = true;
                return result.MakeReadOnly();
            }
            public override Builder MergeFrom(pb::IMessage other)
            {
                if (other is pbMessageHeader)
                {
                    return MergeFrom((pbMessageHeader)other);
                }
                else
                {
                    base.MergeFrom(other);
                    return this;
                }
            }
            public override Builder MergeFrom(pbMessageHeader other)
            {
                if (other == global::Microshaoft.pbMessageHeader.DefaultInstance) return this;
                PrepareBuilder();
                if (other.HasMessageName)
                {
                    MessageName = other.MessageName;
                }
                if (other.HasMessageID)
                {
                    MessageID = other.MessageID;
                }
                this.MergeUnknownFields(other.UnknownFields);
                return this;
            }
            public override Builder MergeFrom(pb::ICodedInputStream input)
            {
                return MergeFrom(input, pb::ExtensionRegistry.Empty);
            }
            public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
            {
                PrepareBuilder();
                pb::UnknownFieldSet.Builder unknownFields = null;
                uint tag;
                string field_name;
                while (input.ReadTag(out tag, out field_name))
                {
                    if (tag == 0 && field_name != null)
                    {
                        int field_ordinal = global::System.Array.BinarySearch(_pbMessageHeaderFieldNames, field_name, global::System.StringComparer.Ordinal);
                        if (field_ordinal >= 0)
                            tag = _pbMessageHeaderFieldTags[field_ordinal];
                        else
                        {
                            if (unknownFields == null)
                            {
                                unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                            }
                            ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                            continue;
                        }
                    }
                    switch (tag)
                    {
                        case 0:
                            {
                                throw pb::InvalidProtocolBufferException.InvalidTag();
                            }
                        default:
                            {
                                if (pb::WireFormat.IsEndGroupTag(tag))
                                {
                                    if (unknownFields != null)
                                    {
                                        this.UnknownFields = unknownFields.Build();
                                    }
                                    return this;
                                }
                                if (unknownFields == null)
                                {
                                    unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                                }
                                ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                                break;
                            }
                        case 10:
                            {
                                result.hasMessageName = input.ReadString(ref result.messageName_);
                                break;
                            }
                        case 16:
                            {
                                result.hasMessageID = input.ReadInt32(ref result.messageID_);
                                break;
                            }
                    }
                }
                if (unknownFields != null)
                {
                    this.UnknownFields = unknownFields.Build();
                }
                return this;
            }
            public bool HasMessageName
            {
                get { return result.hasMessageName; }
            }
            public string MessageName
            {
                get { return result.MessageName; }
                set { SetMessageName(value); }
            }
            public Builder SetMessageName(string value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasMessageName = true;
                result.messageName_ = value;
                return this;
            }
            public Builder ClearMessageName()
            {
                PrepareBuilder();
                result.hasMessageName = false;
                result.messageName_ = "";
                return this;
            }
            public bool HasMessageID
            {
                get { return result.hasMessageID; }
            }
            public int MessageID
            {
                get { return result.MessageID; }
                set { SetMessageID(value); }
            }
            public Builder SetMessageID(int value)
            {
                PrepareBuilder();
                result.hasMessageID = true;
                result.messageID_ = value;
                return this;
            }
            public Builder ClearMessageID()
            {
                PrepareBuilder();
                result.hasMessageID = false;
                result.messageID_ = 0;
                return this;
            }
        }
        static pbMessageHeader()
        {
            object.ReferenceEquals(global::Microshaoft.Test.Descriptor, null);
        }
    }
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
    public sealed partial class pbMessageBody : pb::GeneratedMessage<pbMessageBody, pbMessageBody.Builder>
    {
        private pbMessageBody() { }
        private static readonly pbMessageBody defaultInstance = new pbMessageBody().MakeReadOnly();
        private static readonly string[] _pbMessageBodyFieldNames = new string[] { "F1", "F2", "F3" };
        private static readonly uint[] _pbMessageBodyFieldTags = new uint[] { 10, 16, 26 };
        public static pbMessageBody DefaultInstance
        {
            get { return defaultInstance; }
        }
        public override pbMessageBody DefaultInstanceForType
        {
            get { return DefaultInstance; }
        }
        protected override pbMessageBody ThisMessage
        {
            get { return this; }
        }
        public static pbd::MessageDescriptor Descriptor
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_pbMessageBody__Descriptor; }
        }
        protected override pb::FieldAccess.FieldAccessorTable<pbMessageBody, pbMessageBody.Builder> InternalFieldAccessors
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_pbMessageBody__FieldAccessorTable; }
        }
        public const int F1FieldNumber = 1;
        private bool hasF1;
        private string f1_ = "";
        public bool HasF1
        {
            get { return hasF1; }
        }
        public string F1
        {
            get { return f1_; }
        }
        public const int F2FieldNumber = 2;
        private bool hasF2;
        private int f2_;
        public bool HasF2
        {
            get { return hasF2; }
        }
        public int F2
        {
            get { return f2_; }
        }
        public const int F3FieldNumber = 3;
        private pbc::PopsicleList<global::Microshaoft.ComplexType> f3_ = new pbc::PopsicleList<global::Microshaoft.ComplexType>();
        public scg::IList<global::Microshaoft.ComplexType> F3List
        {
            get { return f3_; }
        }
        public int F3Count
        {
            get { return f3_.Count; }
        }
        public global::Microshaoft.ComplexType GetF3(int index)
        {
            return f3_[index];
        }
        public override bool IsInitialized
        {
            get
            {
                if (!hasF1) return false;
                if (!hasF2) return false;
                foreach (global::Microshaoft.ComplexType element in F3List)
                {
                    if (!element.IsInitialized) return false;
                }
                return true;
            }
        }
        public override void WriteTo(pb::ICodedOutputStream output)
        {
            int size = SerializedSize;
            string[] field_names = _pbMessageBodyFieldNames;
            if (hasF1)
            {
                output.WriteString(1, field_names[0], F1);
            }
            if (hasF2)
            {
                output.WriteInt32(2, field_names[1], F2);
            }
            if (f3_.Count > 0)
            {
                output.WriteMessageArray(3, field_names[2], f3_);
            }
            UnknownFields.WriteTo(output);
        }
        private int memoizedSerializedSize = -1;
        public override int SerializedSize
        {
            get
            {
                int size = memoizedSerializedSize;
                if (size != -1) return size;
                size = 0;
                if (hasF1)
                {
                    size += pb::CodedOutputStream.ComputeStringSize(1, F1);
                }
                if (hasF2)
                {
                    size += pb::CodedOutputStream.ComputeInt32Size(2, F2);
                }
                foreach (global::Microshaoft.ComplexType element in F3List)
                {
                    size += pb::CodedOutputStream.ComputeMessageSize(3, element);
                }
                size += UnknownFields.SerializedSize;
                memoizedSerializedSize = size;
                return size;
            }
        }
        public static pbMessageBody ParseFrom(pb::ByteString data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static pbMessageBody ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static pbMessageBody ParseFrom(byte[] data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static pbMessageBody ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static pbMessageBody ParseFrom(global::System.IO.Stream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static pbMessageBody ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        public static pbMessageBody ParseDelimitedFrom(global::System.IO.Stream input)
        {
            return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
        }
        public static pbMessageBody ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
        }
        public static pbMessageBody ParseFrom(pb::ICodedInputStream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static pbMessageBody ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        private pbMessageBody MakeReadOnly()
        {
            f3_.MakeReadOnly();
            return this;
        }
        public static Builder CreateBuilder() { return new Builder(); }
        public override Builder ToBuilder() { return CreateBuilder(this); }
        public override Builder CreateBuilderForType() { return new Builder(); }
        public static Builder CreateBuilder(pbMessageBody prototype)
        {
            return new Builder(prototype);
        }
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
        public sealed partial class Builder : pb::GeneratedBuilder<pbMessageBody, Builder>
        {
            protected override Builder ThisBuilder
            {
                get { return this; }
            }
            public Builder()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
            }
            internal Builder(pbMessageBody cloneFrom)
            {
                result = cloneFrom;
                resultIsReadOnly = true;
            }
            private bool resultIsReadOnly;
            private pbMessageBody result;
            private pbMessageBody PrepareBuilder()
            {
                if (resultIsReadOnly)
                {
                    pbMessageBody original = result;
                    result = new pbMessageBody();
                    resultIsReadOnly = false;
                    MergeFrom(original);
                }
                return result;
            }
            public override bool IsInitialized
            {
                get { return result.IsInitialized; }
            }
            protected override pbMessageBody MessageBeingBuilt
            {
                get { return PrepareBuilder(); }
            }
            public override Builder Clear()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
                return this;
            }
            public override Builder Clone()
            {
                if (resultIsReadOnly)
                {
                    return new Builder(result);
                }
                else
                {
                    return new Builder().MergeFrom(result);
                }
            }
            public override pbd::MessageDescriptor DescriptorForType
            {
                get { return global::Microshaoft.pbMessageBody.Descriptor; }
            }
            public override pbMessageBody DefaultInstanceForType
            {
                get { return global::Microshaoft.pbMessageBody.DefaultInstance; }
            }
            public override pbMessageBody BuildPartial()
            {
                if (resultIsReadOnly)
                {
                    return result;
                }
                resultIsReadOnly = true;
                return result.MakeReadOnly();
            }
            public override Builder MergeFrom(pb::IMessage other)
            {
                if (other is pbMessageBody)
                {
                    return MergeFrom((pbMessageBody)other);
                }
                else
                {
                    base.MergeFrom(other);
                    return this;
                }
            }
            public override Builder MergeFrom(pbMessageBody other)
            {
                if (other == global::Microshaoft.pbMessageBody.DefaultInstance) return this;
                PrepareBuilder();
                if (other.HasF1)
                {
                    F1 = other.F1;
                }
                if (other.HasF2)
                {
                    F2 = other.F2;
                }
                if (other.f3_.Count != 0)
                {
                    result.f3_.Add(other.f3_);
                }
                this.MergeUnknownFields(other.UnknownFields);
                return this;
            }
            public override Builder MergeFrom(pb::ICodedInputStream input)
            {
                return MergeFrom(input, pb::ExtensionRegistry.Empty);
            }
            public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
            {
                PrepareBuilder();
                pb::UnknownFieldSet.Builder unknownFields = null;
                uint tag;
                string field_name;
                while (input.ReadTag(out tag, out field_name))
                {
                    if (tag == 0 && field_name != null)
                    {
                        int field_ordinal = global::System.Array.BinarySearch(_pbMessageBodyFieldNames, field_name, global::System.StringComparer.Ordinal);
                        if (field_ordinal >= 0)
                            tag = _pbMessageBodyFieldTags[field_ordinal];
                        else
                        {
                            if (unknownFields == null)
                            {
                                unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                            }
                            ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                            continue;
                        }
                    }
                    switch (tag)
                    {
                        case 0:
                            {
                                throw pb::InvalidProtocolBufferException.InvalidTag();
                            }
                        default:
                            {
                                if (pb::WireFormat.IsEndGroupTag(tag))
                                {
                                    if (unknownFields != null)
                                    {
                                        this.UnknownFields = unknownFields.Build();
                                    }
                                    return this;
                                }
                                if (unknownFields == null)
                                {
                                    unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                                }
                                ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                                break;
                            }
                        case 10:
                            {
                                result.hasF1 = input.ReadString(ref result.f1_);
                                break;
                            }
                        case 16:
                            {
                                result.hasF2 = input.ReadInt32(ref result.f2_);
                                break;
                            }
                        case 26:
                            {
                                input.ReadMessageArray(tag, field_name, result.f3_, global::Microshaoft.ComplexType.DefaultInstance, extensionRegistry);
                                break;
                            }
                    }
                }
                if (unknownFields != null)
                {
                    this.UnknownFields = unknownFields.Build();
                }
                return this;
            }
            public bool HasF1
            {
                get { return result.hasF1; }
            }
            public string F1
            {
                get { return result.F1; }
                set { SetF1(value); }
            }
            public Builder SetF1(string value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasF1 = true;
                result.f1_ = value;
                return this;
            }
            public Builder ClearF1()
            {
                PrepareBuilder();
                result.hasF1 = false;
                result.f1_ = "";
                return this;
            }
            public bool HasF2
            {
                get { return result.hasF2; }
            }
            public int F2
            {
                get { return result.F2; }
                set { SetF2(value); }
            }
            public Builder SetF2(int value)
            {
                PrepareBuilder();
                result.hasF2 = true;
                result.f2_ = value;
                return this;
            }
            public Builder ClearF2()
            {
                PrepareBuilder();
                result.hasF2 = false;
                result.f2_ = 0;
                return this;
            }
            public pbc::IPopsicleList<global::Microshaoft.ComplexType> F3List
            {
                get { return PrepareBuilder().f3_; }
            }
            public int F3Count
            {
                get { return result.F3Count; }
            }
            public global::Microshaoft.ComplexType GetF3(int index)
            {
                return result.GetF3(index);
            }
            public Builder SetF3(int index, global::Microshaoft.ComplexType value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.f3_[index] = value;
                return this;
            }
            public Builder SetF3(int index, global::Microshaoft.ComplexType.Builder builderForValue)
            {
                pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
                PrepareBuilder();
                result.f3_[index] = builderForValue.Build();
                return this;
            }
            public Builder AddF3(global::Microshaoft.ComplexType value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.f3_.Add(value);
                return this;
            }
            public Builder AddF3(global::Microshaoft.ComplexType.Builder builderForValue)
            {
                pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
                PrepareBuilder();
                result.f3_.Add(builderForValue.Build());
                return this;
            }
            public Builder AddRangeF3(scg::IEnumerable<global::Microshaoft.ComplexType> values)
            {
                PrepareBuilder();
                result.f3_.Add(values);
                return this;
            }
            public Builder ClearF3()
            {
                PrepareBuilder();
                result.f3_.Clear();
                return this;
            }
        }
        static pbMessageBody()
        {
            object.ReferenceEquals(global::Microshaoft.Test.Descriptor, null);
        }
    }
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
    public sealed partial class ComplexType : pb::GeneratedMessage<ComplexType, ComplexType.Builder>
    {
        private ComplexType() { }
        private static readonly ComplexType defaultInstance = new ComplexType().MakeReadOnly();
        private static readonly string[] _complexTypeFieldNames = new string[] { "FF1", "FF2" };
        private static readonly uint[] _complexTypeFieldTags = new uint[] { 10, 16 };
        public static ComplexType DefaultInstance
        {
            get { return defaultInstance; }
        }
        public override ComplexType DefaultInstanceForType
        {
            get { return DefaultInstance; }
        }
        protected override ComplexType ThisMessage
        {
            get { return this; }
        }
        public static pbd::MessageDescriptor Descriptor
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_ComplexType__Descriptor; }
        }
        protected override pb::FieldAccess.FieldAccessorTable<ComplexType, ComplexType.Builder> InternalFieldAccessors
        {
            get { return global::Microshaoft.Test.internal__static_Microshaoft_ComplexType__FieldAccessorTable; }
        }
        public const int FF1FieldNumber = 1;
        private bool hasFF1;
        private string fF1_ = "";
        public bool HasFF1
        {
            get { return hasFF1; }
        }
        public string FF1
        {
            get { return fF1_; }
        }
        public const int FF2FieldNumber = 2;
        private bool hasFF2;
        private int fF2_;
        public bool HasFF2
        {
            get { return hasFF2; }
        }
        public int FF2
        {
            get { return fF2_; }
        }
        public override bool IsInitialized
        {
            get
            {
                if (!hasFF1) return false;
                if (!hasFF2) return false;
                return true;
            }
        }
        public override void WriteTo(pb::ICodedOutputStream output)
        {
            int size = SerializedSize;
            string[] field_names = _complexTypeFieldNames;
            if (hasFF1)
            {
                output.WriteString(1, field_names[0], FF1);
            }
            if (hasFF2)
            {
                output.WriteInt32(2, field_names[1], FF2);
            }
            UnknownFields.WriteTo(output);
        }
        private int memoizedSerializedSize = -1;
        public override int SerializedSize
        {
            get
            {
                int size = memoizedSerializedSize;
                if (size != -1) return size;
                size = 0;
                if (hasFF1)
                {
                    size += pb::CodedOutputStream.ComputeStringSize(1, FF1);
                }
                if (hasFF2)
                {
                    size += pb::CodedOutputStream.ComputeInt32Size(2, FF2);
                }
                size += UnknownFields.SerializedSize;
                memoizedSerializedSize = size;
                return size;
            }
        }
        public static ComplexType ParseFrom(pb::ByteString data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static ComplexType ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static ComplexType ParseFrom(byte[] data)
        {
            return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
        }
        public static ComplexType ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
        }
        public static ComplexType ParseFrom(global::System.IO.Stream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static ComplexType ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        public static ComplexType ParseDelimitedFrom(global::System.IO.Stream input)
        {
            return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
        }
        public static ComplexType ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
        {
            return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
        }
        public static ComplexType ParseFrom(pb::ICodedInputStream input)
        {
            return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
        }
        public static ComplexType ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
        {
            return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
        }
        private ComplexType MakeReadOnly()
        {
            return this;
        }
        public static Builder CreateBuilder() { return new Builder(); }
        public override Builder ToBuilder() { return CreateBuilder(this); }
        public override Builder CreateBuilderForType() { return new Builder(); }
        public static Builder CreateBuilder(ComplexType prototype)
        {
            return new Builder(prototype);
        }
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("ProtoGen", "2.3.0.277")]
        public sealed partial class Builder : pb::GeneratedBuilder<ComplexType, Builder>
        {
            protected override Builder ThisBuilder
            {
                get { return this; }
            }
            public Builder()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
            }
            internal Builder(ComplexType cloneFrom)
            {
                result = cloneFrom;
                resultIsReadOnly = true;
            }
            private bool resultIsReadOnly;
            private ComplexType result;
            private ComplexType PrepareBuilder()
            {
                if (resultIsReadOnly)
                {
                    ComplexType original = result;
                    result = new ComplexType();
                    resultIsReadOnly = false;
                    MergeFrom(original);
                }
                return result;
            }
            public override bool IsInitialized
            {
                get { return result.IsInitialized; }
            }
            protected override ComplexType MessageBeingBuilt
            {
                get { return PrepareBuilder(); }
            }
            public override Builder Clear()
            {
                result = DefaultInstance;
                resultIsReadOnly = true;
                return this;
            }
            public override Builder Clone()
            {
                if (resultIsReadOnly)
                {
                    return new Builder(result);
                }
                else
                {
                    return new Builder().MergeFrom(result);
                }
            }
            public override pbd::MessageDescriptor DescriptorForType
            {
                get { return global::Microshaoft.ComplexType.Descriptor; }
            }
            public override ComplexType DefaultInstanceForType
            {
                get { return global::Microshaoft.ComplexType.DefaultInstance; }
            }
            public override ComplexType BuildPartial()
            {
                if (resultIsReadOnly)
                {
                    return result;
                }
                resultIsReadOnly = true;
                return result.MakeReadOnly();
            }
            public override Builder MergeFrom(pb::IMessage other)
            {
                if (other is ComplexType)
                {
                    return MergeFrom((ComplexType)other);
                }
                else
                {
                    base.MergeFrom(other);
                    return this;
                }
            }
            public override Builder MergeFrom(ComplexType other)
            {
                if (other == global::Microshaoft.ComplexType.DefaultInstance) return this;
                PrepareBuilder();
                if (other.HasFF1)
                {
                    FF1 = other.FF1;
                }
                if (other.HasFF2)
                {
                    FF2 = other.FF2;
                }
                this.MergeUnknownFields(other.UnknownFields);
                return this;
            }
            public override Builder MergeFrom(pb::ICodedInputStream input)
            {
                return MergeFrom(input, pb::ExtensionRegistry.Empty);
            }
            public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
            {
                PrepareBuilder();
                pb::UnknownFieldSet.Builder unknownFields = null;
                uint tag;
                string field_name;
                while (input.ReadTag(out tag, out field_name))
                {
                    if (tag == 0 && field_name != null)
                    {
                        int field_ordinal = global::System.Array.BinarySearch(_complexTypeFieldNames, field_name, global::System.StringComparer.Ordinal);
                        if (field_ordinal >= 0)
                            tag = _complexTypeFieldTags[field_ordinal];
                        else
                        {
                            if (unknownFields == null)
                            {
                                unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                            }
                            ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                            continue;
                        }
                    }
                    switch (tag)
                    {
                        case 0:
                            {
                                throw pb::InvalidProtocolBufferException.InvalidTag();
                            }
                        default:
                            {
                                if (pb::WireFormat.IsEndGroupTag(tag))
                                {
                                    if (unknownFields != null)
                                    {
                                        this.UnknownFields = unknownFields.Build();
                                    }
                                    return this;
                                }
                                if (unknownFields == null)
                                {
                                    unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
                                }
                                ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
                                break;
                            }
                        case 10:
                            {
                                result.hasFF1 = input.ReadString(ref result.fF1_);
                                break;
                            }
                        case 16:
                            {
                                result.hasFF2 = input.ReadInt32(ref result.fF2_);
                                break;
                            }
                    }
                }
                if (unknownFields != null)
                {
                    this.UnknownFields = unknownFields.Build();
                }
                return this;
            }
            public bool HasFF1
            {
                get { return result.hasFF1; }
            }
            public string FF1
            {
                get { return result.FF1; }
                set { SetFF1(value); }
            }
            public Builder SetFF1(string value)
            {
                pb::ThrowHelper.ThrowIfNull(value, "value");
                PrepareBuilder();
                result.hasFF1 = true;
                result.fF1_ = value;
                return this;
            }
            public Builder ClearFF1()
            {
                PrepareBuilder();
                result.hasFF1 = false;
                result.fF1_ = "";
                return this;
            }
            public bool HasFF2
            {
                get { return result.hasFF2; }
            }
            public int FF2
            {
                get { return result.FF2; }
                set { SetFF2(value); }
            }
            public Builder SetFF2(int value)
            {
                PrepareBuilder();
                result.hasFF2 = true;
                result.fF2_ = value;
                return this;
            }
            public Builder ClearFF2()
            {
                PrepareBuilder();
                result.hasFF2 = false;
                result.fF2_ = 0;
                return this;
            }
        }
        static ComplexType()
        {
            object.ReferenceEquals(global::Microshaoft.Test.Descriptor, null);
        }
    }
    #endregion
}
#endregion Designer generated code

posted @ 2012-04-02 03:36  于斯人也  阅读(3926)  评论(0编辑  收藏  举报