本文整理汇总了C#中System.Reflection.MethodInfo.IsPropertySetter方法的典型用法代码示例。如果您正苦于以下问题:C# MethodInfo.IsPropertySetter方法的具体用法?C# MethodInfo.IsPropertySetter怎么用?C# MethodInfo.IsPropertySetter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.IsPropertySetter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TimestampedPropertyVersionDelta
public TimestampedPropertyVersionDelta(object setValue, MethodInfo targetSite, long timeStamp, bool isActive = true)
: base(new[]{setValue}, targetSite, timeStamp, isActive)
{
if( ! targetSite.IsPropertySetter())
throw new Exception(string.Format("method {0} is not a property setter.", targetSite));
var actualType = targetSite.GetParameters().Single().ParameterType;
if (setValue == null && actualType.IsValueType && actualType != typeof(Nullable<>)) //nullable being a struct is annoying.
throw new Exception(String.Format("Attempting to set null to a value type"));
//actually looking at the comments from microsoft symbole servers on nullable, Microsoft seems to think the whole concept
//of nullable is pretty annoying. Wierd serialization issues.
if (setValue != null && ! setValue.GetType().IsAssignableTo(actualType))
throw new Exception(String.Format("supplied value to set is not the correct type. Supplied value is a {0} but the setter is setting a {1}",
setValue.GetType(), actualType));
}
示例2: GetMethodCall
// TODO Property formating
// TODO ParamArray method
// TODO Void members
// TODO indexers
private string GetMethodCall(MethodInfo method)
{
if (method.IsPropertyGetter())
{
return method.Name.Substring(4) + " → " + this.ReturnValue;
}
if (method.IsPropertySetter())
{
return method.Name.Substring(4) + " = " + this.GetValue(this.Arguments.ElementAt(0).Value);
}
var methodCall = this.Method + "(" +
string.Join(",", this.Arguments.Select(a => GetKind(a) + a.Name + ": " + a.Value.ToString()).ToArray()) + ")";
if (this.IsVoid)
{
return methodCall;
}
return " → " + this.ReturnValue.ToString();
}