/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public IValueConverter Converter {
+ public IValueConverter Converter
+ {
get { return _converter; }
- set {
+ set
+ {
ThrowIfApplied();
_converter = value;
}
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public object ConverterParameter {
+ public object ConverterParameter
+ {
get { return _converterParameter; }
- set {
+ set
+ {
ThrowIfApplied();
_converterParameter = value;
}
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public object Source {
+ public object Source
+ {
get { return _source; }
- set {
+ set
+ {
ThrowIfApplied();
_source = value;
}
}
- internal string UpdateSourceEventName {
+ internal string UpdateSourceEventName
+ {
get { return _updateSourceEventName; }
- set {
+ set
+ {
ThrowIfApplied();
_updateSourceEventName = value;
}
{
readonly Func<TSource, TProperty> _getter;
readonly Action<TSource, TProperty> _setter;
- readonly PropertyChangedProxy [] _handlers;
+ readonly PropertyChangedProxy[] _handlers;
- public TypedBinding(Func<TSource, TProperty> getter, Action<TSource, TProperty> setter, Tuple<Func<TSource, object>, string> [] handlers)
+ public TypedBinding(Func<TSource, TProperty> getter, Action<TSource, TProperty> setter, Tuple<Func<TSource, object>, string>[] handlers)
{
if (getter == null)
throw new ArgumentNullException(nameof(getter));
if (handlers == null)
return;
- _handlers = new PropertyChangedProxy [handlers.Length];
+ _handlers = new PropertyChangedProxy[handlers.Length];
for (var i = 0; i < handlers.Length; i++)
- _handlers [i] = new PropertyChangedProxy(handlers [i].Item1, handlers [i].Item2, this);
+ _handlers[i] = new PropertyChangedProxy(handlers[i].Item1, handlers[i].Item2, this);
}
readonly WeakReference<object> _weakSource = new WeakReference<object>(null);
return;
base.Apply(source, bindObj, targetProperty, fromBindingContextChanged);
-
+
#if (!DO_NOT_CHECK_FOR_BINDING_REUSE)
BindableObject prevTarget;
if (_weakTarget.TryGetTarget(out prevTarget) && !ReferenceEquals(prevTarget, bindObj))
internal override BindingBase Clone()
{
- Tuple<Func<TSource, object>, string> [] handlers = _handlers == null ? null : new Tuple<Func<TSource, object>, string> [_handlers.Length];
- if (handlers != null) {
+ Tuple<Func<TSource, object>, string>[] handlers = _handlers == null ? null : new Tuple<Func<TSource, object>, string>[_handlers.Length];
+ if (handlers != null)
+ {
for (var i = 0; i < _handlers.Length; i++)
- handlers [i] = new Tuple<Func<TSource, object>, string>(_handlers [i].PartGetter, _handlers [i].PropertyName);
+ handlers[i] = new Tuple<Func<TSource, object>, string>(_handlers[i].PartGetter, _handlers[i].PropertyName);
}
- return new TypedBinding<TSource, TProperty>(_getter, _setter, handlers) {
+ return new TypedBinding<TSource, TProperty>(_getter, _setter, handlers)
+ {
Mode = Mode,
Converter = Converter,
ConverterParameter = ConverterParameter,
#endif
if (_handlers != null)
Unsubscribe();
-
+
#if (!DO_NOT_CHECK_FOR_BINDING_REUSE)
_weakSource.SetTarget(null);
_weakTarget.SetTarget(null);
if (isTSource && (mode == BindingMode.OneWay || mode == BindingMode.TwoWay) && _handlers != null)
Subscribe((TSource)sourceObject);
- if (needsGetter) {
+ if (needsGetter)
+ {
var value = property.DefaultValue;
- if (isTSource) {
- try {
+ if (isTSource)
+ {
+ try
+ {
value = GetSourceValue(_getter((TSource)sourceObject), property.ReturnType);
- } catch (Exception ex) when (ex is NullReferenceException || ex is KeyNotFoundException) {
+ }
+ catch (Exception ex) when (ex is NullReferenceException || ex is KeyNotFoundException)
+ {
}
}
- if (!TryConvert(ref value, property, property.ReturnType, true)) {
+ if (!TryConvert(ref value, property, property.ReturnType, true))
+ {
// Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
return;
}
}
var needsSetter = (mode == BindingMode.TwoWay && fromTarget) || mode == BindingMode.OneWayToSource;
- if (needsSetter && _setter != null && isTSource) {
+ if (needsSetter && _setter != null && isTSource)
+ {
var value = GetTargetValue(target.GetValue(property), typeof(TProperty));
- if (!TryConvert(ref value, property, typeof(TProperty), false)) {
+ if (!TryConvert(ref value, property, typeof(TProperty), false))
+ {
// Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, typeof(TProperty));
return;
}
return true;
object original = value;
- try {
+ try
+ {
value = Convert.ChangeType(value, convertTo, CultureInfo.InvariantCulture);
return true;
- } catch (Exception ex ) when (ex is InvalidCastException || ex is FormatException||ex is OverflowException) {
+ }
+ catch (Exception ex) when (ex is InvalidCastException || ex is FormatException || ex is OverflowException)
+ {
value = original;
return false;
}
WeakReference<INotifyPropertyChanged> _weakPart = new WeakReference<INotifyPropertyChanged>(null);
readonly BindingBase _binding;
- public INotifyPropertyChanged Part {
- get {
+ public INotifyPropertyChanged Part
+ {
+ get
+ {
INotifyPropertyChanged target;
if (_weakPart.TryGetTarget(out target))
return target;
return null;
- }
- set {
+ }
+ set
+ {
_weakPart.SetTarget(value);
Listener.SubscribeTo(value, OnPropertyChanged);
}
void Subscribe(TSource sourceObject)
{
- for (var i = 0; i < _handlers.Length; i++) {
- var part = _handlers [i].PartGetter(sourceObject);
+ for (var i = 0; i < _handlers.Length; i++)
+ {
+ var part = _handlers[i].PartGetter(sourceObject);
if (part == null)
break;
var inpc = part as INotifyPropertyChanged;
if (inpc == null)
continue;
- _handlers [i].Part = (inpc);
+ _handlers[i].Part = (inpc);
}
}
void Unsubscribe()
{
for (var i = 0; i < _handlers.Length; i++)
- _handlers [i].Listener.Unsubscribe();
+ _handlers[i].Listener.Unsubscribe();
}
}
}
\ No newline at end of file