/// <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 )); }
/// <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 )); }
protected void OnPropertyChanged <T>(Expression <Func <T> > propertySelector) { string propertyName = ExpressionService.GetPropertyName(propertySelector); OnPropertyChanged(propertyName); }