本文整理汇总了C#中BindableObject.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# BindableObject.GetType方法的具体用法?C# BindableObject.GetType怎么用?C# BindableObject.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindableObject
的用法示例。
在下文中一共展示了BindableObject.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvalidBindableException
/// <summary>
/// Constructs the exception and passes a meaningful
/// message to the base Exception
/// </summary>
/// <param name="bindable">The bindable object that was passed</param>
/// <param name="expected">The expected type</param>
/// <param name="name">The calling methods name, uses [CallerMemberName]</param>
public InvalidBindableException(BindableObject bindable, Type expected,[CallerMemberName]string name=null)
: base(string.Format("Invalid bindable passed to {0} expected a {1} received a {2}", name, expected.Name, bindable.GetType().Name))
{
}
示例2: ApplyCore
/// <summary>
/// Applies the binding expression to a previously set source or target.
/// </summary>
void ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget = false)
{
BindingMode mode = Binding.GetRealizedMode(_targetProperty);
if (mode == BindingMode.OneWay && fromTarget)
return;
bool needsGetter = (mode == BindingMode.TwoWay && !fromTarget) || mode == BindingMode.OneWay;
bool needsSetter = !needsGetter && ((mode == BindingMode.TwoWay && fromTarget) || mode == BindingMode.OneWayToSource);
object current = sourceObject;
object previous = null;
BindingExpressionPart part = null;
for (var i = 0; i < _parts.Count; i++)
{
part = _parts[i];
bool isLast = i + 1 == _parts.Count;
if (!part.IsSelf && current != null)
{
// Allow the object instance itself to provide its own TypeInfo
var reflectable = current as IReflectableType;
TypeInfo currentType = reflectable != null ? reflectable.GetTypeInfo() : current.GetType().GetTypeInfo();
if (part.LastGetter == null || !part.LastGetter.DeclaringType.GetTypeInfo().IsAssignableFrom(currentType))
SetupPart(currentType, part);
if (!isLast)
part.TryGetValue(current, out current);
}
if (!part.IsSelf && current != null)
{
if ((needsGetter && part.LastGetter == null) || (needsSetter && part.NextPart == null && part.LastSetter == null))
{
Log.Warning("Binding", PropertyNotFoundErrorMessage, part.Content, current, target.GetType(), property.PropertyName);
break;
}
}
if (mode == BindingMode.OneWay || mode == BindingMode.TwoWay)
{
var inpc = current as INotifyPropertyChanged;
if (inpc != null && !ReferenceEquals(current, previous))
{
// If we're reapplying, we don't want to double subscribe
inpc.PropertyChanged -= part.ChangeHandler;
inpc.PropertyChanged += part.ChangeHandler;
}
}
previous = current;
}
Debug.Assert(part != null, "There should always be at least the self part in the expression.");
if (needsGetter)
{
object value = property.DefaultValue;
if (part.TryGetValue(current, out value) || part.IsSelf)
{
value = Binding.GetSourceValue(value, property.ReturnType);
}
else
value = property.DefaultValue;
if (!TryConvert(part, ref value, property.ReturnType, true))
{
Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
return;
}
target.SetValueCore(property, value, BindableObject.SetValueFlags.ClearDynamicResource, BindableObject.SetValuePrivateFlags.Default | BindableObject.SetValuePrivateFlags.Converted);
}
else if (needsSetter && part.LastSetter != null && current != null)
{
object value = Binding.GetTargetValue(target.GetValue(property), part.SetterType);
if (!TryConvert(part, ref value, part.SetterType, false))
{
Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, part.SetterType);
return;
}
object[] args;
if (part.IsIndexer)
{
args = new object[part.Arguments.Length + 1];
part.Arguments.CopyTo(args, 0);
args[args.Length - 1] = value;
}
else if (part.IsBindablePropertySetter)
{
args = new[] { part.BindablePropertyField, value };
}
else
{
args = new[] { value };
//.........这里部分代码省略.........