#region Copyright notice and license
#endregion
using System;
using System.Reflection;
using Google.Protobuf.Compatibility;
namespace Google.Protobuf.Reflection
{
internal abstract class FieldAccessorBase : IFieldAccessor
{
private readonly Func<IMessage, object> getValueDelegate;
internal FieldAccessorBase(PropertyInfo property, FieldDescriptor descriptor)
{
Descriptor = descriptor;
getValueDelegate = ReflectionUtil.CreateFuncIMessageObject(property.GetGetMethod());
}
public FieldDescriptor Descriptor { get; }
public object GetValue(IMessage message)
{
return getValueDelegate(message);
}
public abstract bool HasValue(IMessage message);
public abstract void Clear(IMessage message);
public abstract void SetValue(IMessage message, object value);
}
}