コード例 #1
0
 /// <summary>
 ///   Creates a new 'PropertyPath' that throws a 'NullReferenceException'
 ///   when 'GetValue' or 'SetValue' is called and one of the property path
 ///   steps (except the last) return null. To create a 'PropertyPath' for
 ///   the 'Address.City' property of the 'Person' class call
 ///   '<![CDATA[Create<Person, string>(p => p.Address.City)]]>'.
 /// </summary>
 public static PropertyPath <TSource, TValue> Create <TSource, TValue>(
     Expression <Func <TSource, TValue> > propertyPathSelector
     )
 {
     return(new PropertyPath <TSource, TValue>(
                ExpressionService.GetProperties(propertyPathSelector),
                useDefaultValue: false
                ));
 }
コード例 #2
0
 /// <summary>
 ///   Creates a new 'PropertyPath' that returns the given 'defaultValue'
 ///   when 'GetValue' is called and one of the property path steps (except
 ///   the last) returns null. Calls to 'SetValue' do nothinng in this case.
 ///   To create a 'PropertyPath' for the 'Address.City' property of the
 ///   'Person' class call  '<![CDATA[
 ///      CreateWithDefaultValue<Person, string>(p => p.Address.City, "Unknown")
 ///   ]]>'.
 /// </summary>
 public static PropertyPath <TSource, TValue> CreateWithDefaultValue <TSource, TValue>(
     Expression <Func <TSource, TValue> > propertyPathSelector,
     TValue defaultValue = default(TValue)
     )
 {
     return(new PropertyPath <TSource, TValue>(
                ExpressionService.GetProperties(propertyPathSelector),
                useDefaultValue: true,
                defaultValue: defaultValue
                ));
 }
コード例 #3
0
        protected void OnPropertyChanged <T>(Expression <Func <T> > propertySelector)
        {
            string propertyName = ExpressionService.GetPropertyName(propertySelector);

            OnPropertyChanged(propertyName);
        }