本文整理汇总了C#中System.Reflection.ParameterModifier类的典型用法代码示例。如果您正苦于以下问题:C# ParameterModifier类的具体用法?C# ParameterModifier怎么用?C# ParameterModifier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterModifier类属于System.Reflection命名空间,在下文中一共展示了ParameterModifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectMethod
/// <summary>
/// The only method we implement. Our goal here is to find a method that best matches the arguments passed.
/// We are doing this only with the intent of pulling attached property metadata off of the method.
/// If there are ambiguous methods, we simply take the first one as all "Get" methods for an attached
/// property should have identical metadata.
/// </summary>
public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
{
// Short circuit for cases where someone didn't pass in a types array.
if (types == null)
{
if (match.Length > 1)
{
throw new AmbiguousMatchException();
}
else
{
return match[0];
}
}
for(int idx = 0; idx < match.Length; idx++)
{
MethodBase candidate = match[idx];
ParameterInfo[] parameters = candidate.GetParameters();
if (ParametersMatch(parameters, types))
{
return candidate;
}
}
return null;
}
示例2: BindToMethod
public override MethodBase BindToMethod(
BindingFlags bindingAttr,
MethodBase[] match,
ref object[] args,
ParameterModifier[] modifiers,
CultureInfo culture,
string[] names,
out object state
)
{
for (int i = 0; i < args.Length; i++)
{
if (args[i] is string)
{
args[i] = ChangeType(args[i], typeof(string), culture);
}
if (args[i] is int)
{
args[i] = ChangeType(args[i], typeof(int), culture);
}
if (args[i] is bool)
{
args[i] = ChangeType(args[i], typeof(bool), culture);
}
}
return Type.DefaultBinder.BindToMethod(
bindingAttr,
match,
ref args,
modifiers,
culture,
names,
out state
);
}
示例3: SelectMethod
public override MethodBase SelectMethod(
BindingFlags bindingAttr,
MethodBase[] matchMethods,
Type[] parameterTypes,
ParameterModifier[] modifiers)
{
for (int i = 0; i < matchMethods.Length; ++i)
{
if (matchMethods[i].IsGenericMethodDefinition != _genericMethodDefinition)
continue;
ParameterInfo[] pis = matchMethods[i].GetParameters();
bool match = (pis.Length == parameterTypes.Length);
for (int j = 0; match && j < pis.Length; ++j)
{
match = TypeHelper.CompareParameterTypes(pis[j].ParameterType, parameterTypes[j]);
}
if (match)
return matchMethods[i];
}
return null;
}
示例4: SelectMethod
public override MethodBase SelectMethod(
BindingFlags bindingAttr,
MethodBase[] matchMethods,
Type[] parameterTypes,
ParameterModifier[] modifiers) {
for (int i = 0; i < matchMethods.Length; ++i) {
if (matchMethods[i].IsGenericMethodDefinition == _genericMethodDefinition) {
ParameterInfo[] pis = matchMethods[i].GetParameters();
bool match = (pis.Length == parameterTypes.Length);
for (int j = 0; match && j < pis.Length; ++j) {
if (pis[j].ParameterType == parameterTypes[j])
continue;
if (pis[j].ParameterType.IsGenericParameter)
match = CheckGenericTypeConstraints(pis[j].ParameterType, parameterTypes[j]);
else if (pis[j].ParameterType.IsGenericType && parameterTypes[j].IsGenericType)
match = CompareGenericTypesRecursive(pis[j].ParameterType, parameterTypes[j]);
else
match = false;
}
if (match)
return matchMethods[i];
}
}
return null;
}
示例5: AddNamedCommand
public Command AddNamedCommand(string commandName, string text, string tooltip,
ResourceBitmaps bitmapId, int status) {
ParameterModifier pm = new ParameterModifier(7);
for (int i = 0; i < 7; i++) {
pm[i] = false;
}
// the 7th argument is a ref parameter
pm[6] = true;
return (Command) commandsType.InvokeMember(
"AddNamedCommand2", BindingFlags.InvokeMethod, null,
commands, new object[] {
Context.AddInInstance,
commandName,
text,
tooltip,
true,
59,
contextGuids
// The status parameter is not passed (yet)
// VS 2005 beta2 breaks with this parameter
// we will add it when most people have switched to final
},
new ParameterModifier[] {pm}, null, null);
}
示例6:
PropertyInfo IReflect.GetProperty(string name, BindingFlags bindingAttr,
Binder binder, Type returnType, Type[] types,
ParameterModifier[] modifiers)
{
return this.GetType().GetProperty(name, bindingAttr, binder,
returnType, types, modifiers);
}
示例7: BindToMethod
public override MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
{
object[] array = new object[args.Length];
args.CopyTo(array, 0);
state = null;
try
{
return this.defltBinder.BindToMethod(bindingAttr, match, ref args, modifiers, culture, names, out state);
}
catch (MissingMethodException)
{
if ((match != null) && (match.Length != 0))
{
for (int i = 0; i < match.Length; i++)
{
ParameterInfo[] parameters = match[i].GetParameters();
if (parameters.Length == array.Length)
{
for (int j = 0; j < parameters.Length; j++)
{
if (!parameters[j].ParameterType.IsInstanceOfType(array[j]) && (!parameters[j].ParameterType.IsArray || (array[j] != null)))
{
break;
}
if ((j + 1) == parameters.Length)
{
return match[i];
}
}
}
}
}
}
return null;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:35,代码来源:ExternalDataExchangeBinder.cs
示例8: GetMethod
public string GetMethod(string methodName, params IType[] args)
{
if (args.Any(a => a as AsmType == null))
return null;
var types = args.Select(t => (t as AsmType).Type).ToArray();
MethodInfo method = null;
if (args.Length > 0)
{
var modifiers = args.Select(arg => arg.Modifier == TypeModifier.Reference).ToArray();
var mods = new ParameterModifier[] { new ParameterModifier(modifiers.Length) };
for (var i = 0; i < modifiers.Length; i++)
mods[0][i] = modifiers[i];
method = Type.GetMethod(methodName, types, mods);
}
else
method = Type.GetMethod(methodName);
if (method == null)
return null;
var returnType = new AsmType(method.ReturnType);
var parameters = method.GetParameters()
.Select(p => new AsmType(p.ParameterType));
return string.Format("{0} {1}::{2}({3})",
returnType.Name, Name, methodName,
string.Join(", ", parameters.Select(p => p.Name)));
}
示例9: BindToMethod
// Bind a set of arguments to a method.
public abstract MethodBase BindToMethod(BindingFlags bindingAttr,
MethodBase[] match,
ref Object[] args,
ParameterModifier[] modifiers,
CultureInfo culture,
String[] names,
ref Object state);
示例10: ProcessRequest
/// <summary>
/// Process client request
/// </summary>
/// <param name="arguments">Query string parameters</param>
/// <param name="request">Http context request</param>
/// <returns>Number indicated http-request code (for exmpl. 200, 404, 403, 500)</returns>
public virtual Int32 ProcessRequest(String[] arguments, System.Web.HttpRequest request)
{
String methodName = String.Concat("action_", arguments[0]);
Type[] methodArgs1 = new Type[] { typeof(String[]) };
Type[] methodArgs0 = new Type[0];
ParameterModifier[] modifier = new ParameterModifier[0];
BindingFlags bflags = BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
// метод с параметром
MethodInfo method = this.GetType().GetMethod(methodName, bflags, Type.DefaultBinder, methodArgs1, modifier)
?? this.GetType().GetMethod(methodName, bflags, Type.DefaultBinder, methodArgs0, modifier);
if (method == null)
{
return 404;
}
try
{
return (Int32)method.Invoke(this, method.GetParameters().Length == 0 ? null : new Object[] {arguments});
}
catch (Exception excpn)
{
Logger.Error(this.GetType(), String.Format("Failed to invoke {0} method", methodName), excpn);
return 500;
}
}
示例11: SelectMethod
public override MethodBase SelectMethod(BindingFlags bindingAttr,
MethodBase[] match,
Type[] types,
ParameterModifier[] modifiers)
{
// TODO
return null;
}
示例12: GetMethodValidated
internal static MethodInfo GetMethodValidated(this Type type, string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
{
MethodInfo mi = type.GetMethod(name, bindingAttr, binder, types, modifiers);
if (!mi.MatchesArgumentTypes(types))
{
return null;
}
return mi;
}
示例13:
// Invoke a specific type member.
public override Object InvokeMember
(String name, BindingFlags invokeAttr, Binder binder,
Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
{
return builder.InvokeMember(name, invokeAttr, binder,
target, args, modifiers,
culture, namedParameters);
}
示例14: GetConstructorImpl
protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr,
Binder binder,
CallingConventions callConvention,
Type[] types,
ParameterModifier[] modifiers)
{
ConstructorInfo[] methods = GetConstructors (bindingAttr);
return GetConstructorImpl (methods, bindingAttr, binder, callConvention, types, modifiers);
}
示例15: InvokeMember
internal object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
{
Type type = base.GetType();
if (!type.IsCOMObject)
{
throw new InvalidOperationException(Environment.GetResourceString("Arg_InvokeMember"));
}
return type.InvokeMember(name, invokeAttr, binder, this, args, modifiers, culture, namedParameters);
}