Пример #1
0
 public Builder SetEmbedded(global::Protobuf.EmbeddedMessage.Builder builderForValue)
 {
     pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
     PrepareBuilder();
     result.hasEmbedded = true;
     result.embedded_   = builderForValue.Build();
     return(this);
 }
Пример #2
0
            public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
            {
                PrepareBuilder();
                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(_testMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
                        if (field_ordinal >= 0)
                        {
                            tag = _testMessageFieldTags[field_ordinal];
                        }
                        else
                        {
                            ParseUnknownField(input, extensionRegistry, tag, field_name);
                            continue;
                        }
                    }
                    switch (tag)
                    {
                    case 0: {
                        throw pb::InvalidProtocolBufferException.InvalidTag();
                    }

                    default: {
                        if (pb::WireFormat.IsEndGroupTag(tag))
                        {
                            return(this);
                        }
                        ParseUnknownField(input, extensionRegistry, tag, field_name);
                        break;
                    }

                    case 8: {
                        result.hasId = input.ReadInt32(ref result.id_);
                        break;
                    }

                    case 18: {
                        global::Protobuf.EmbeddedMessage.Builder subBuilder = global::Protobuf.EmbeddedMessage.CreateBuilder();
                        if (result.hasEmbedded)
                        {
                            subBuilder.MergeFrom(Embedded);
                        }
                        input.ReadMessage(subBuilder, extensionRegistry);
                        Embedded = subBuilder.BuildPartial();
                        break;
                    }

                    case 26: {
                        result.hasText = input.ReadString(ref result.text_);
                        break;
                    }
                    }
                }

                return(this);
            }