diff options
author | Jon Skeet <skeet@pobox.com> | 2008-08-14 20:35:27 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2008-08-14 20:35:27 +0100 |
commit | f26f8dce0279b3cd0ee9708bfca322be5c19d4f7 (patch) | |
tree | d5165af45b3bcc0243518ad766eb358f04a0980e /csharp/ProtocolBuffers/ExtendableBuilder.cs | |
parent | 9134a21f27728996237010449fe9273b3bf4be78 (diff) | |
download | protobuf-f26f8dce0279b3cd0ee9708bfca322be5c19d4f7.tar.gz protobuf-f26f8dce0279b3cd0ee9708bfca322be5c19d4f7.tar.bz2 protobuf-f26f8dce0279b3cd0ee9708bfca322be5c19d4f7.zip |
The great generics revisiting.
Diffstat (limited to 'csharp/ProtocolBuffers/ExtendableBuilder.cs')
-rw-r--r-- | csharp/ProtocolBuffers/ExtendableBuilder.cs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/csharp/ProtocolBuffers/ExtendableBuilder.cs b/csharp/ProtocolBuffers/ExtendableBuilder.cs index 0c96ace6..b55d4b99 100644 --- a/csharp/ProtocolBuffers/ExtendableBuilder.cs +++ b/csharp/ProtocolBuffers/ExtendableBuilder.cs @@ -13,57 +13,55 @@ namespace Google.ProtocolBuffers { /// <summary> /// Checks if a singular extension is present /// </summary> - public bool HasExtension<TExtension>(GeneratedExtensionBase<TMessage, TExtension> extension) { + public bool HasExtension<TExtension>(GeneratedExtensionBase<TExtension> extension) { return MessageBeingBuilt.HasExtension(extension); } /// <summary> /// Returns the number of elements in a repeated extension. /// </summary> - public int GetExtensionCount<TExtension>(GeneratedExtensionBase<TMessage, IList<TExtension>> extension) { + public int GetExtensionCount<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension) { return MessageBeingBuilt.GetExtensionCount(extension); } /// <summary> /// Returns the value of an extension. /// </summary> - public TExtension GetExtension<TExtension>(GeneratedExtensionBase<TMessage, TExtension> extension) { + public TExtension GetExtension<TExtension>(GeneratedExtensionBase<TExtension> extension) { return MessageBeingBuilt.GetExtension(extension); } /// <summary> /// Returns one element of a repeated extension. /// </summary> - public TExtension GetExtension<TExtension>(GeneratedExtensionBase<TMessage, IList<TExtension>> extension, int index) { + public TExtension GetExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, int index) { return MessageBeingBuilt.GetExtension(extension, index); } /// <summary> /// Sets the value of an extension. /// </summary> - public ExtendableBuilder<TMessage, TBuilder> SetExtension<TExtension>(GeneratedExtensionBase<TMessage, TExtension> extension, TExtension value) { + public TBuilder SetExtension<TExtension>(GeneratedExtensionBase<TExtension> extension, TExtension value) { ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt; message.VerifyExtensionContainingType(extension); message.Extensions[extension.Descriptor] = extension.ToReflectionType(value); - return this; + return ThisBuilder; } /// <summary> /// Sets the value of one element of a repeated extension. /// </summary> - public ExtendableBuilder<TMessage, TBuilder> SetExtension<TExtension>( - GeneratedExtensionBase<TMessage, IList<TExtension>> extension, int index, TExtension value) { + public TBuilder SetExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, int index, TExtension value) { ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt; message.VerifyExtensionContainingType(extension); message.Extensions[extension.Descriptor, index] = extension.SingularToReflectionType(value); - return this; + return ThisBuilder; } /// <summary> /// Appends a value to a repeated extension. /// </summary> - public ExtendableBuilder<TMessage, TBuilder> AddExtension<TExtension>( - GeneratedExtensionBase<TMessage, IList<TExtension>> extension, TExtension value) { + public ExtendableBuilder<TMessage, TBuilder> AddExtension<TExtension>(GeneratedExtensionBase<IList<TExtension>> extension, TExtension value) { ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt; message.VerifyExtensionContainingType(extension); message.Extensions.AddRepeatedField(extension.Descriptor, extension.SingularToReflectionType(value)); @@ -73,8 +71,7 @@ namespace Google.ProtocolBuffers { /// <summary> /// Clears an extension. /// </summary> - public ExtendableBuilder<TMessage, TBuilder> ClearExtension<TExtension>( - GeneratedExtensionBase<TMessage, TExtension> extension) { + public ExtendableBuilder<TMessage, TBuilder> ClearExtension<TExtension>(GeneratedExtensionBase<TExtension> extension) { ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt; message.VerifyExtensionContainingType(extension); message.Extensions.ClearField(extension.Descriptor); @@ -121,23 +118,23 @@ namespace Google.ProtocolBuffers { } } - public override IBuilder<TMessage> ClearField(FieldDescriptor field) { + public override TBuilder ClearField(FieldDescriptor field) { if (field.IsExtension) { ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt; message.VerifyContainingType(field); message.Extensions.ClearField(field); - return this; + return ThisBuilder; } else { return base.ClearField(field); } } - public override IBuilder<TMessage> AddRepeatedField(FieldDescriptor field, object value) { + public override TBuilder AddRepeatedField(FieldDescriptor field, object value) { if (field.IsExtension) { ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt; message.VerifyContainingType(field); message.Extensions.AddRepeatedField(field, value); - return this; + return ThisBuilder; } else { return base.AddRepeatedField(field, value); } |