本文整理汇总了C#中System.Reflection.PropertyInfo.Last方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.Last方法的具体用法?C# PropertyInfo.Last怎么用?C# PropertyInfo.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.Last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindingBridge
internal BindingBridge(IBindingSourceInternal source, PropertyInfo sourcePropery, PropertyInfo[] targetProperyChain)
{
MyBindingSource = source;
SourcePropertyInfo = sourcePropery;
TargetPropertyChain = targetProperyChain;
bool fromSource = SourcePropertyInfo.CanRead && TargetPropertyChain.Last ().CanWrite;
bool fromTarget = SourcePropertyInfo.CanWrite && TargetPropertyChain.Last ().CanRead
&& MyBindingSource.Controler.BackwardProperties.Contains (TargetPropertyName);
if (fromSource && fromTarget)
Mode = BridgeMode.TwoWay;
else if (fromSource)
Mode = BridgeMode.OnlyFromSource;
else if (fromTarget)
Mode = BridgeMode.BackwardFromTarget;
else
throw new ArgumentException ("Невозможно вычислить направление биндинга, необходимо что бы хотябы одно свойство имело возможность записи, а другое чтение.");
}
示例2: GetValue
public object GetValue(object entity, PropertyInfo[] accessorList)
{
var obj = entity;
for (int x = 0; x < accessorList.Length - 1; x++)
{
obj = accessorList[x].GetValue(obj, null);
}
return accessorList.Last().GetValue(obj, null);
}
示例3: SetValue
public void SetValue(object entity, PropertyInfo[] accessorList, object propertyValue)
{
if (propertyValue == DBNull.Value) return;
var obj = entity;
for (int x = 0; x < accessorList.Length - 1; x++)
{
obj = accessorList[x].GetValue(obj, null);
}
var accessor = accessorList.Last();
if (accessor.PropertyType.IsEnum)
{
propertyValue = Enum.ToObject(accessor.PropertyType, propertyValue);
}
else if (!accessor.PropertyType.IsAssignableFrom(propertyValue.GetType()))
{
propertyValue = Convert.ChangeType(propertyValue, accessor.PropertyType);
}
accessor.SetValue(obj, propertyValue, null);
}