本文整理汇总了C#中System.Reflection.Binder.ConvertValues方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.ConvertValues方法的具体用法?C# Binder.ConvertValues怎么用?C# Binder.ConvertValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Binder
的用法示例。
在下文中一共展示了Binder.ConvertValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoInvoke
object DoInvoke (object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
if (binder == null)
binder = Binder.DefaultBinder;
ParameterInfo[] pinfo = MonoMethodInfo.GetParametersInfo (mhandle, this);
binder.ConvertValues (parameters, pinfo, culture, (invokeAttr & BindingFlags.ExactBinding) != 0);
#if !NET_2_1
if (SecurityManager.SecurityEnabled) {
// sadly Attributes doesn't tell us which kind of security action this is so
// we must do it the hard way - and it also means that we can skip calling
// Attribute (which is another an icall)
SecurityManager.ReflectedLinkDemandInvoke (this);
}
#endif
if (obj == null && DeclaringType.ContainsGenericParameters)
throw new MemberAccessException ("Cannot create an instance of " + DeclaringType + " because Type.ContainsGenericParameters is true.");
if ((invokeAttr & BindingFlags.CreateInstance) != 0 && DeclaringType.IsAbstract) {
throw new MemberAccessException (String.Format ("Cannot create an instance of {0} because it is an abstract class", DeclaringType));
}
return InternalInvoke (obj, parameters);
}
示例2: Invoke
public override Object Invoke (Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
{
if (binder == null)
binder = Binder.DefaultBinder;
/*Avoid allocating an array every time*/
ParameterInfo[] pinfo = GetParametersInternal ();
binder.ConvertValues (parameters, pinfo, culture, (invokeAttr & BindingFlags.ExactBinding) != 0);
#if !NET_2_1
if (SecurityManager.SecurityEnabled) {
// sadly Attributes doesn't tell us which kind of security action this is so
// we must do it the hard way - and it also means that we can skip calling
// Attribute (which is another an icall)
SecurityManager.ReflectedLinkDemandInvoke (this);
}
#endif
if (ContainsGenericParameters)
throw new InvalidOperationException ("Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true.");
Exception exc;
object o = null;
try {
// The ex argument is used to distinguish exceptions thrown by the icall
// from the exceptions thrown by the called method (which need to be
// wrapped in TargetInvocationException).
o = InternalInvoke (obj, parameters, out exc);
} catch (ThreadAbortException) {
throw;
#if NET_2_1
} catch (MethodAccessException) {
throw;
#endif
} catch (Exception e) {
throw new TargetInvocationException (e);
}
if (exc != null)
throw exc;
return o;
}