public object?Convert(object?value, Type?targetType, object?parameter, CultureInfo?culture) { if (!IsConvertFunctionAvailable) { EventSource.Log.MissingConvertFunction("convertFunction", ErrorStrategy.ToString()); return(GetErrorValue(DefaultOutputTypeValue)); } if (targetType != null) { if (!targetType.IsAssignableFrom(OutputType)) { EventSource.Log.NonAssignableTargetType(targetType.Name, OutputType.Name, ErrorStrategy.ToString()); return(GetErrorValue(DefaultOutputTypeValue)); } } else { EventSource.Log.NonRequestedTargetType(); } return(ConvertInternal(value, parameter, culture)); }
public override ValidationResult?Validate(object?value, CultureInfo?cultureInfo) { if (ruleFunction == null) { EventSource.Log.MissingRuleFunction("ruleFunction", ErrorStrategy.ToString()); return(GetErrorValue()); } return(ValidateInternal(value, cultureInfo)); }
public override DataTemplate?SelectTemplate(object?item, DependencyObject?container) { if (selectFunction == null) { EventSource.Log.MissingSelectTemplateFunction("selectFunction", ErrorStrategy.ToString()); return(GetErrorValue()); } return(SelectTemplateInternal(item, container)); }
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { if (!IsConvertBackFunctionAvailable) { EventSource.Log.MissingConvertBackFunction("convertBackFunction", ErrorStrategy.ToString()); return(GetErrorValues(DefaultInputTypeValue, targetTypes)); } if (targetTypes != null) { for (var i = 0; i < targetTypes.Length; i++) { var targetType = targetTypes[i]; if (targetType != null) { if (!targetType.IsAssignableFrom(InputType)) { EventSource.Log.NonAssignableTargetTypeAtPositionForBackConversion( targetType.Name, i, InputType.Name, ErrorStrategy.ToString()); return(GetErrorValues(DefaultInputTypeValue, targetTypes)); } } else { EventSource.Log.NonRequestedTargetTypeAtPosition(i); } } } else { EventSource.Log.NonRequestedTargetType(); } return(ConvertBackInternal(value, targetTypes, parameter, culture)); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { if (!IsConvertBackFunctionAvailable) { EventSource.Log.MissingConvertBackFunction("convertBackFunction", ErrorStrategy.ToString()); return(GetErrorValue(DefaultInputTypeValue)); } if (targetType != null) { if (!targetType.IsAssignableFrom(InputType)) { EventSource.Log.NonAssignableTargetTypeForBackConversion(targetType.Name, InputType.Name, ErrorStrategy.ToString()); return(GetErrorValue(DefaultInputTypeValue)); } } else { EventSource.Log.NonRequestedTargetType(); } return(ConvertBackInternal(value, parameter, culture)); }
ValidationResult?ValidateInternal(object?item, CultureInfo?cultureInfo) { I inputValue; try { inputValue = (I)item !; } catch (SystemException e) when(e is InvalidCastException || e is NullReferenceException) { EventSource.Log.UnableToCastToRuleInputType(item?.GetType().Name ?? "null", typeof(I).Name, ErrorStrategy.ToString()); return(GetErrorValue()); } Debug.Assert(ruleFunction != null); return(ruleFunction !(new ValidationRuleArgs <I>(inputValue, cultureInfo))); }
DataTemplate?SelectTemplateInternal(object?item, DependencyObject?container) { I inputValue; try { inputValue = (I)item !; } catch (SystemException e) when(e is InvalidCastException || e is NullReferenceException) { EventSource.Log.UnableToCastToItemType(item?.GetType().Name ?? "null", typeof(I).Name, ErrorStrategy.ToString()); return(GetErrorValue()); } Debug.Assert(selectFunction != null); return(selectFunction !(new TemplateSelectorArgs <I>(inputValue, container))); }