本文整理汇总了C#中IDictionaryAdapter.SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionaryAdapter.SetProperty方法的具体用法?C# IDictionaryAdapter.SetProperty怎么用?C# IDictionaryAdapter.SetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionaryAdapter
的用法示例。
在下文中一共展示了IDictionaryAdapter.SetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
public void CopyTo(IDictionaryAdapter other, Func<PropertyDescriptor, bool> selector)
{
if (ReferenceEquals(this, other))
{
return;
}
if (other.Meta.Type.IsAssignableFrom(Meta.Type) == false)
{
throw new ArgumentException(string.Format(
"Unable to copy to {0}. The type must be assignable from {1}.",
other.Meta.Type.FullName, Meta.Type.FullName));
}
if (This.CopyStrategies.Aggregate(false, (copied, s) => copied | s.Copy(this, other, ref selector)))
{
return;
}
selector = selector ?? (property => true);
foreach (var property in This.Properties.Values.Where(property => selector(property)))
{
var propertyValue = GetProperty(property.PropertyName, true);
other.SetProperty(property.PropertyName, ref propertyValue);
}
}
示例2: CopyTo
public void CopyTo(IDictionaryAdapter other, Predicate<PropertyDescriptor> selector)
{
if (Meta.Type.IsAssignableFrom(other.Meta.Type) == false)
{
throw new ArgumentException(string.Format(
"Unable to copy to {0}. The type must be assignable from {1}.",
other.Meta.Type.FullName, Meta.Type.FullName));
}
if (This.CopyStrategy != null && This.CopyStrategy.Copy(this, other, ref selector))
{
return;
}
selector = selector ?? (p => true);
foreach (var property in This.Properties.Values.Where(p => selector(p)))
{
var propertyValue = GetProperty(property.PropertyName, true);
other.SetProperty(property.PropertyName, ref propertyValue);
}
}