Ejemplo 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;
 }
Ejemplo n.º 2
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;
 }