diff options
author | Jon Skeet <skeet@pobox.com> | 2008-08-14 20:37:12 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2008-08-14 20:37:12 +0100 |
commit | 272d384f6ad064756edc8d9778c5bcf667783821 (patch) | |
tree | eed1435ff63c89a52e426df79323a9b1c1bef24a /csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs | |
parent | db9d2fcd06bd8604f2ff9f30489640f64c70c4cb (diff) | |
download | protobuf-272d384f6ad064756edc8d9778c5bcf667783821.tar.gz protobuf-272d384f6ad064756edc8d9778c5bcf667783821.tar.bz2 protobuf-272d384f6ad064756edc8d9778c5bcf667783821.zip |
Use delegates instead of dynamic reflection.
Diffstat (limited to 'csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs')
-rw-r--r-- | csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs b/csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs index 7945f461..460d450d 100644 --- a/csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs +++ b/csharp/ProtocolBuffers/FieldAccess/SingleMessageAccessor.cs @@ -20,7 +20,9 @@ namespace Google.ProtocolBuffers.FieldAccess { /// <summary> /// Accessor for fields representing a non-repeated message value. /// </summary> - internal sealed class SingleMessageAccessor : SinglePrimitiveAccessor { + internal sealed class SingleMessageAccessor<TMessage, TBuilder> : SinglePrimitiveAccessor<TMessage, TBuilder> + where TMessage : IMessage<TMessage, TBuilder> + where TBuilder : IBuilder<TMessage, TBuilder> { /// <summary> /// The static method to create a builder for the property type. For example, @@ -30,8 +32,7 @@ namespace Google.ProtocolBuffers.FieldAccess { private readonly MethodInfo createBuilderMethod; - internal SingleMessageAccessor(string name, Type messageType, Type builderType) - : base(name, messageType, builderType) { + internal SingleMessageAccessor(string name) : base(name) { createBuilderMethod = ClrType.GetMethod("CreateBuilder", new Type[0]);//BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly); if (createBuilderMethod == null) { @@ -55,7 +56,7 @@ namespace Google.ProtocolBuffers.FieldAccess { return CreateBuilder().WeakMergeFrom(message).WeakBuild(); } - public override void SetValue(IBuilder builder, object value) { + public override void SetValue(TBuilder builder, object value) { base.SetValue(builder, CoerceType(value)); } |