Exemplo n.º 1
0
 /// <summary>
 /// Creates a new fetcher for a field
 /// </summary>
 /// <param name="field">Field info</param>
 public ExpressionTreeFetcher(FieldInfo field) : base(field.Name)
 {
     Kind     = FetcherKind.Field;
     _getFunc = Getters.GetOrAdd(field, f => ExpressionAccessors.BuildGetAccessor((FieldInfo)f));
     _setFunc = Setters.GetOrAdd(field, f => (((FieldInfo)f).Attributes & FieldAttributes.InitOnly) == 0 ? ExpressionAccessors.BuildSetAccessor((FieldInfo)f) : EmptySetter);
     _invoker = EmptyInvoker;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new fetcher for a method
 /// </summary>
 /// <param name="method">Field info</param>
 public ExpressionTreeFetcher(MethodInfo method) : base(method.Name)
 {
     Kind     = FetcherKind.Method;
     _getFunc = EmptyGetter;
     _setFunc = EmptySetter;
     _invoker = Invokers.GetOrAdd(method, minfo => ExpressionAccessors.BuildMethodAccessor(minfo));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new fetcher for a property
 /// </summary>
 /// <param name="property">Property info</param>
 public ExpressionTreeFetcher(PropertyInfo property) : base(property.Name)
 {
     Kind     = FetcherKind.Property;
     _getFunc = Getters.GetOrAdd(property, prop => ((PropertyInfo)prop).CanRead ? ExpressionAccessors.BuildGetAccessor((PropertyInfo)prop) : EmptyGetter);
     _setFunc = Setters.GetOrAdd(property, prop => ((PropertyInfo)prop).CanWrite ? ExpressionAccessors.BuildSetAccessor((PropertyInfo)prop) : EmptySetter);
     _invoker = EmptyInvoker;
 }