Example #1
0
        } = true;                                 // TODO really always true?

        public void SetValue(TItem item, string identifier)
        {
            var    propertyInfo   = PropertyInfoUtilities.GetPropertyInfoFromLambda(_getterExpr);
            object convertedValue = ConversionUtility.ConvertValue(identifier, propertyInfo.PropertyType);

            propertyInfo.SetValue(item, convertedValue);

            // TODO use below?
            //IdentifierExpressionHelpers.SetIdentifier(item, _getterExpr, identifier);
        }
Example #2
0
 // TODO: Put strings into the resources.
 //
 public static ArgumentUtilitiesHandle <PropertyInfo> EnsureNonStaticRead(this ArgumentUtilitiesHandle <PropertyInfo> hnd, out MethodInfo getAccessor)
 {
     if (!(hnd.Value is null))
     {
         if (!PropertyInfoUtilities.IsNonStaticRead(hnd: hnd, getAccessor: out getAccessor))
         {
             throw
                 new ArgumentException(
                     message: $"Указанное свойство является недоступным для чтения.{Environment.NewLine}\tСвойство:{hnd.Value.FmtStr().GNLI2()}",
                     paramName: hnd.Name);
         }
     }
Example #3
0
 // TODO: Put exception messages into the resources.
 //
 public static ArgumentUtilitiesHandle <PropertyInfo> EnsureNonStatic(this ArgumentUtilitiesHandle <PropertyInfo> hnd, out MethodInfo getAccessor, out MethodInfo setAccessor)
 {
     if (hnd.Value != null)
     {
         if (!PropertyInfoUtilities.IsNonStatic(hnd, out getAccessor, out setAccessor))
         {
             throw
                 new ArgumentException(
                     paramName: hnd.Name,
                     message: $"Указанное свойство является статическим.{Environment.NewLine}\tСвойство:{hnd.Value.FmtStr().GNLI2()}");
         }
     }
     else
     {
         getAccessor = null;
         setAccessor = null;
     }
     return(hnd);
 }
 public PropertyInfoFieldReader([NotNull] PropertyInfo propertyInfo)
 {
     PropertyInfoUtilities.EnsureValidProperty <TItem>(propertyInfo);
     _propertyInfo = propertyInfo;
 }
 public PropertyExpressionFieldWriter([NotNull] Expression <Func <TItem, TProperty> > propertyExpression)
     : base(PropertyInfoUtilities.GetPropertyInfoFromLambda(propertyExpression))
 {
 }