Pomona.Common.TypeSystem.PropertySpec.OnLoadSetter C# (CSharp) Method

OnLoadSetter() protected method

protected OnLoadSetter ( ) : PropertySetter
return PropertySetter
        protected internal virtual PropertySetter OnLoadSetter()
        {
            if (!PropertyInfo.CanWrite)
                return null;

            var selfParam = Expression.Parameter(typeof(object), "x");
            var valueParam = Expression.Parameter(typeof(object), "value");
            var expr = Expression.Lambda<Action<object, object, IContainer>>(
                Expression.Assign(
                    Expression.Property(
                        Expression.Convert(selfParam, PropertyInfo.DeclaringType),
                        PropertyInfo
                        ),
                    Expression.Convert(valueParam, PropertyInfo.PropertyType)
                    ),
                selfParam,
                valueParam,
                Expression.Parameter(typeof(IContainer), "ctx"));

            return new PropertySetter(expr.Compile());
        }

Usage Example

Ejemplo n.º 1
0
 public virtual PropertySetter LoadSetter(PropertySpec propertySpec)
 {
     if (propertySpec == null)
     {
         throw new ArgumentNullException(nameof(propertySpec));
     }
     return(propertySpec.OnLoadSetter());
 }
All Usage Examples Of Pomona.Common.TypeSystem.PropertySpec::OnLoadSetter