private void InitializeSet(bool enableDelegateCaching) { var setMethod = this.PropertyInfo.GetSetMethod(true); if (setMethod == null) { return; } this.CanSet = true; this.IsStatic = setMethod.IsStatic; this.PublicSet = setMethod.IsPublic; if (enableDelegateCaching) { this.Setter = MemberAccessorDelegateBuilder.CachedPropertyBuilder.BuildGenericSetter(this.PropertyInfo); } else { var builder = new PropertyAccessorLambdaBuilder(false); this.Setter = builder.BuildGenericSetter(this.PropertyInfo).Compile(); } }
public GenericPropertySetter BuildGenericSetter(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw new ArgumentNullException(nameof(propertyInfo)); } if (EnableCaching) { if (genericSetterCache.TryGetValue(propertyInfo, out var cachedDelegate)) { return((GenericPropertySetter)cachedDelegate); } } var delegate_ = builder.BuildGenericSetter(propertyInfo).Compile(); if (EnableCaching) { genericSetterCache.TryAdd(propertyInfo, delegate_); } return(delegate_); }