public virtual void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var handler = PropertyChanged; if (!object.Equals(handler, null)) { var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); if (!object.Equals(propertyName, null)) { var args = new PropertyChangedEventArgs(propertyName); var dispatcher = WindowWrapper.Current().Dispatcher; if (dispatcher.HasThreadAccess()) { try { handler.Invoke(this, args); } catch { dispatcher.Dispatch(() => handler.Invoke(this, args)); } } else { dispatcher.Dispatch(() => handler.Invoke(this, args)); } } } }
public void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { if (DesignMode.DesignModeEnabled) { return; } var handler = PropertyChanged; //if is not null if (Equals(handler, null)) { return; } var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); if (Equals(propertyName, null)) { return; } var args = new PropertyChangedEventArgs(propertyName); try { handler.Invoke(this, args); } catch { WindowWrapper.Current().Dispatcher.Dispatch(() => handler.Invoke(this, args)); } }
public static void Update <T>(this T item, T source, params Expression <Func <T, object> >[] properties) { foreach (var func in properties) { var propertyName = ExpressionUtils.GetPropertyName(func); item.SetValue(source.GetValue(propertyName), propertyName); } }
protected virtual void OnPropertyChanged <T>(Expression <Func <T> > expression) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(ExpressionUtils.GetPropertyName(expression))); } }
public static ValidationError Create <TProperty>(Expression <Func <TProperty> > propertySelector, string errorMessage) { Ensure.NotNull(propertySelector); Ensure.NotEmpty(errorMessage); string propertyName = ExpressionUtils.GetPropertyName(propertySelector); return(new ValidationError(propertyName, errorMessage)); }
public virtual void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
public static void ClearErrors <TError, TProperty>(this IErrorsContainer <TError> errorsContainer, Expression <Func <TProperty> > propertySelector) where TError : ValidationError { Ensure.NotNull(errorsContainer); Ensure.NotNull(propertySelector); string propertyName = ExpressionUtils.GetPropertyName(propertySelector); errorsContainer.ClearErrors(propertyName); }
public static IEnumerable <TError> GetErrors <TError, TProperty>(this IErrorsContainer <TError> errorsContainer, Expression <Func <TProperty> > propertySelector) where TError : ValidationError { Ensure.NotNull(errorsContainer); Ensure.NotNull(propertySelector); string propertyName = ExpressionUtils.GetPropertyName(propertySelector); return(errorsContainer.GetErrors(propertyName)); }
public PropertyVM Create <Te, Tp>(Expression <Func <Te, Tp> > selector, object instance) { var propertyInfo = ExpressionUtils.GetPropertyInfo(selector); var propertyName = ExpressionUtils.GetPropertyName(selector); // var value = selector.Compile().Invoke((Te) _htmlHelper.ViewData.Model); return(Create <Tp>(propertyName, propertyInfo, instance)); }
public static TagBuilder LabelFor <Te, Tp>(this HtmlHelper <Te> htmlHelper, Expression <Func <Te, Tp> > selector) where Te : class { var propertyInfo = ExpressionUtils.GetPropertyInfo(selector); var builder = new ExTagBuilder("label"); builder.Attributes.Add("for", ExpressionUtils.GetPropertyName(selector)); builder.InnerHtml = Config.DescriptionProvider.GetProperty(propertyInfo, htmlHelper.ViewData.Model).DisplayName; return(builder); }
private static int GetColumnIndex <T>(Expression <Func <Salary, T> > columnSelector, string[] columnNames) { string columnName = ExpressionUtils.GetPropertyName(columnSelector); int columnIndex = Array.FindIndex(columnNames, x => x == columnName); if (columnIndex == -1) { Assert.Fail("column not found"); } return(columnIndex); }
public static void ClearErrors <TError, TEntity, TProperty>( this IErrorsContainer <TError> errorContainer, Expression <Func <TEntity, TProperty> > propertyExpression) where TError : ValidationError { if (propertyExpression == null) { throw new ArgumentNullException("propertyExpression"); } string propertyName = ExpressionUtils.GetPropertyName(propertyExpression); errorContainer.ClearErrors(propertyName); }
public virtual void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { var handler = PropertyChanged; //if is not null if (!object.Equals(handler, null)) { var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); if (!object.Equals(propertyName, null)) { handler(this, new PropertyChangedEventArgs(propertyName)); } } }
/// <summary> /// Registers a callback to be invoked when the PropertyChanged event has been raised for the specified property. /// </summary> /// <param name="expression">A lambda expression like 'n => n.PropertyName'.</param> /// <param name="handler">The callback to invoke when the property has changed.</param> /// <returns>The object on which this method was invoked, to allow for multiple invocations chained together.</returns> public PropertyObserver <TPropertySource> RegisterHandler( Expression <Func <TPropertySource, object> > expression, Action <TPropertySource> handler) { Ensure.NotNull(expression, "expression"); Ensure.NotNull(handler, "handler"); string propertyName = ExpressionUtils.GetPropertyName(expression); TPropertySource propertySource = GetPropertySource(); if (propertySource != null) { propertyNameToHandlerMap[propertyName] = handler; PropertyChangedEventManager.AddListener(propertySource, this, propertyName); } return(this); }
public virtual void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); if (!object.Equals(propertyName, null)) { try { OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); } catch { } } }
/// <summary> /// Removes the callback associated with the specified property. /// </summary> /// <param name="expression">A lambda expression like 'n => n.PropertyName'.</param> /// <returns>The object on which this method was invoked, to allow for multiple invocations chained together.</returns> public PropertyObserver <TPropertySource> UnregisterHandler(Expression <Func <TPropertySource, object> > expression) { Ensure.NotNull(expression, "expression"); string propertyName = ExpressionUtils.GetPropertyName(expression); TPropertySource propertySource = GetPropertySource(); if (propertySource != null) { if (propertyNameToHandlerMap.ContainsKey(propertyName)) { propertyNameToHandlerMap.Remove(propertyName); PropertyChangedEventManager.RemoveListener(propertySource, this, propertyName); } } return(this); }
public virtual void RaisePropertyChanged <T>(Expression <Func <T> > propertyExpression) { if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } var handler = PropertyChanged; if (!Equals(handler, null)) { var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); if (Equals(propertyName, null)) { return; } var args = new PropertyChangedEventArgs(propertyName); handler.Invoke(this, args); } }
public static void UpdateByMeta <T>(this T item, T source, params Expression <Func <T, object> >[] exept) { var exeptProperties = exept.Select(e => ExpressionUtils.GetPropertyName(e)).ToList(); foreach (var property in item.GetType().GetProperties()) { if (exeptProperties.Contains(property.Name)) { continue; } var isMapping = property.HasAttribute(typeof(ColumnAttribute)); if (property.CanWrite && isMapping) { property.SetValue(item, property.GetValue(source)); } } }
protected void OnPropertyChanged <T>(Expression <Func <T> > propertyExpression) { var propertyName = ExpressionUtils.GetPropertyName(propertyExpression); OnPropertyChanged(propertyName); }
public IOrderedSearchClient <T> ThenBy(Expression <Func <T, object> > expression) { var propertyName = ExpressionUtils.GetPropertyName(expression); return(ThenBy(propertyName)); }
protected virtual void OnPropertyChanged <T>(Expression <Func <T> > expression) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(ExpressionUtils.GetPropertyName(expression))); }
public ISearchClient <T> WithinRadiusOf(Expression <Func <T, object> > expression, GeoLocation geoLocation, double km) { var propertyName = ExpressionUtils.GetPropertyName(expression); return(WithinRadiusOf(propertyName, geoLocation, km)); }
public IOrderedSearchClient <T> OrderByDescending(Expression <Func <T, object> > expression) { var propertyName = ExpressionUtils.GetPropertyName(expression); return(OrderByDescending(propertyName)); }
public static Facet ForProperty <T>(this FacetsList <T> facets, Expression <Func <T, object> > expression) where T : SearchModelBase { var propertyName = ExpressionUtils.GetPropertyName(expression); return(facets.Where(x => x.PropetyName.Equals(propertyName)).SingleOrDefault()); }
public static string CombineVariable <C, T>(string variableKey, Expression <Func <C, T> > expression, bool checkVariablekey = true) { string combineStr = "." + ExpressionUtils.GetPropertyName(expression); return(CombineVariable(variableKey, combineStr, checkVariablekey)); }