本文整理汇总了C#中System.Reflection.MethodInfo类的典型用法代码示例。如果您正苦于以下问题:C# System.Reflection.MethodInfo类的具体用法?C# System.Reflection.MethodInfo怎么用?C# System.Reflection.MethodInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Reflection.MethodInfo类属于命名空间,在下文中一共展示了System.Reflection.MethodInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DispatchExceptionFailureEventArgs
public DispatchExceptionFailureEventArgs(Exception ex, IQHsm hsm, System.Reflection.MethodInfo stateMethod, IQEvent ev)
{
_Exception = ex;
_Hsm = hsm;
_StateMethod = stateMethod;
_OriginalEvent = ev;
}
示例2: ProcessParams
public override bool ProcessParams(MethodInfo method, int paramNum, IFacetHolder holder) {
ParameterInfo parameter = method.GetParameters()[paramNum];
Attribute attribute = parameter.GetCustomAttributeByReflection<DescriptionAttribute>();
if (attribute == null) {
attribute = parameter.GetCustomAttributeByReflection<DescribedAsAttribute>();
}
return FacetUtils.AddFacet(Create(attribute, holder));
}
示例3: Process
public override bool Process(MethodInfo method, IMethodRemover methodRemover, IFacetHolder holder) {
var classAttribute = method.DeclaringType.GetCustomAttributeByReflection<AuthorizeActionAttribute>();
var methodAttribute = method.GetCustomAttribute<AuthorizeActionAttribute>();
if (classAttribute != null && methodAttribute != null) {
Log.WarnFormat("Class and method level AuthorizeAttributes applied to class {0} - ignoring attribute on method {1}", method.DeclaringType.FullName, method.Name);
}
return Create(classAttribute ?? methodAttribute, holder);
}
示例4: BuildAccessor
private static System.Func<object, object> BuildAccessor(MethodInfo method)
{
ParameterExpression obj = Expression.Parameter(typeof(object), "obj");
UnaryExpression instance = !method.IsStatic ? Expression.Convert(obj, method.DeclaringType) : null;
Expression<System.Func<object, object>> expr = Expression.Lambda<System.Func<object, object>>(
Expression.Convert(
Expression.Call(instance, method),
typeof(object)),
obj);
return expr.Compile();
}
示例5: MdaMethodImpl
// ------------------------------------------------------------------------
// private final MdaClass parentMdaClass; .. see super
// private final String methodName; .. see super.getName
// constructors
// -------------------------------------------------------------------------
public MdaMethodImpl(MdaClass parentMdaClass, int internalMethodIndex,
System.Reflection.MethodInfo method, PropertiesNode tags)
: base(method.Name, tags, parentMdaClass)
{
this.internalMethodIndex = internalMethodIndex;
this.method = method;
this.returnType = method.ReturnType;
if (returnType == null)
{
throw new System.InvalidOperationException("returnType == null for Method " + this);
}
}
示例6: Message
public Message(MessageID msgid, string msgname, Int16 length, List<Byte> msgargtypes, System.Reflection.MethodInfo msghandler)
{
id = msgid;
name = msgname;
msglen = length;
handler = msghandler;
argtypes = new System.Reflection.MethodInfo[msgargtypes.Count];
for(int i=0; i<msgargtypes.Count; i++)
{
argtypes[i] = StreamRWBinder.bindReader(msgargtypes[i]);
if(argtypes[i] == null)
{
Dbg.ERROR_MSG("Message::Message(): bindReader(" + msgargtypes[i] + ") is error!");
}
}
// Dbg.DEBUG_MSG(string.Format("Message::Message(): ({0}/{1}/{2})!",
// msgname, msgid, msglen));
}
示例7: Process
public override bool Process(MethodInfo actionMethod, IMethodRemover methodRemover, IFacetHolder action) {
string capitalizedName = NameUtils.CapitalizeName(actionMethod.Name);
Type type = actionMethod.DeclaringType;
var facets = new List<IFacet>();
INakedObjectSpecification onType = Reflector.LoadSpecification(type);
INakedObjectSpecification returnSpec = Reflector.LoadSpecification(actionMethod.ReturnType);
RemoveMethod(methodRemover, actionMethod);
facets.Add(new ActionInvocationFacetViaMethod(actionMethod, onType, returnSpec, action));
MethodType methodType = actionMethod.IsStatic ? MethodType.Class : MethodType.Object;
Type[] paramTypes = actionMethod.GetParameters().Select(p => p.ParameterType).ToArray();
FindAndRemoveValidMethod(facets, methodRemover, type, methodType, capitalizedName, paramTypes, action);
DefaultNamedFacet(facets, capitalizedName, action); // must be called after the checkForXxxPrefix methods
AddHideForSessionFacetNone(facets, action);
AddDisableForSessionFacetNone(facets, action);
FindDefaultHideMethod(facets, methodRemover, type, methodType, "ActionDefault", paramTypes, action);
FindAndRemoveHideMethod(facets, methodRemover, type, methodType, capitalizedName, paramTypes, action);
FindDefaultDisableMethod(facets, methodRemover, type, methodType, "ActionDefault", paramTypes, action);
FindAndRemoveDisableMethod(facets, methodRemover, type, methodType, capitalizedName, paramTypes, action);
if (action is DotNetNakedObjectActionPeer) {
var nakedObjectActionPeer = (DotNetNakedObjectActionPeer) action;
// Process the action's parameters names, descriptions and optional
// an alternative design would be to have another facet factory processing just ActionParameter, and have it remove these
// supporting methods. However, the FacetFactory API doesn't allow for methods of the class to be removed while processing
// action parameters, only while processing Methods (ie actions)
INakedObjectActionParamPeer[] actionParameters = nakedObjectActionPeer.Parameters;
string[] paramNames = actionMethod.GetParameters().Select(p => p.Name).ToArray();
FindAndRemoveParametersAutoCompleteMethod(methodRemover, type, capitalizedName, paramTypes, actionParameters);
FindAndRemoveParametersChoicesMethod(methodRemover, type, capitalizedName, paramTypes, paramNames, actionParameters);
FindAndRemoveParametersDefaultsMethod(methodRemover, type, capitalizedName, paramTypes, paramNames, actionParameters);
FindAndRemoveParametersValidateMethod(methodRemover, type, capitalizedName, paramTypes, paramNames, actionParameters);
}
return FacetUtils.AddFacets(facets);
}
示例8: Message
public Message(MessageID msgid, string msgname, Int16 length, sbyte argstype, List<Byte> msgargtypes, System.Reflection.MethodInfo msghandler)
{
id = msgid;
name = msgname;
msglen = length;
handler = msghandler;
argsType = argstype;
// 对该消息的所有参数绑定反序列化方法,改方法能够将二进制流转化为参数需要的值
// 在服务端下发消息数据时会用到
argtypes = new KBEDATATYPE_BASE[msgargtypes.Count];
for(int i=0; i<msgargtypes.Count; i++)
{
if(!EntityDef.id2datatypes.TryGetValue(msgargtypes[i], out argtypes[i]))
{
Dbg.ERROR_MSG("Message::Message(): argtype(" + msgargtypes[i] + ") is not found!");
}
}
// Dbg.DEBUG_MSG(string.Format("Message::Message(): ({0}/{1}/{2})!",
// msgname, msgid, msglen));
}
示例9: DisplayMethodProperties
public void DisplayMethodProperties(System.Reflection.MethodInfo Method)
{
ThisMethod = Method;
// Show the method name
Label2.Text = ThisMethod.Name;
// Show the calling convention
Label4.Text = "0x" + ThisMethod.CallingConvention.ToString("x") +
" = " + ThisMethod.CallingConvention.ToString();
// Show the method's standard attributes
Label6.Text = "0x" + ThisMethod.Attributes.ToString("x") +
" = " + ThisMethod.Attributes.ToString();
// Show the return type
Label8.Text = ThisMethod.ReturnType.FullName;
// Show the parameters
foreach (System.Reflection.ParameterInfo parm in ThisMethod.GetParameters())
{
//ListBox1.Items.Add(parm.Name + " as " + parm.ParameterType.FullName);
ListBox1.Items.Add(parm.ParameterType);//changed because I need the type later
}
// Show the custom attributes
foreach (object attr in ThisMethod.GetCustomAttributes(true))
{
ListBox2.Items.Add(attr);
}
}
示例10: Bridge
public Bridge()
{
this.lDomain = System.AppDomain.CurrentDomain;
this.LoadTypes();
this.lTimeout = 30000;
lHandleEventMethod = this.GetType().GetMethod("HandleEvent");
this.timerhotkey = new System.Timers.Timer(100);
this.timerhotkey.Elapsed += new System.Timers.ElapsedEventHandler(TimerCheckHotKey);
AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
}
示例11: Init
public override void Init(Reactor reactor)
{
base.Init(reactor);
var cm = reactor.FindMethod (functionName);
if (cm == null) {
Debug.LogError ("Could not load function method: " + functionName);
} else {
component = cm.component;
methodInfo = cm.methodInfo;
}
}
示例12: ObjectBusMessageDeserializerAttribute
public ObjectBusMessageDeserializerAttribute(Type type, string funcName)
{
if (funcName == null)
throw new ArgumentNullException ("funcName");
func = type.GetMethod (funcName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
if (func == null) {
Console.Write ("ObjectBusMessageDeserializerAttribute is going into failsafe mode, ");
func = type.GetMethod (funcName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
if (func == null)
Console.WriteLine ("failed.");
else
Console.WriteLine ("succeeded.");
}
}
示例13: SnowballFilter
/// <summary>Construct the named stemming filter.
///
/// </summary>
/// <param name="in">the input tokens to stem
/// </param>
/// <param name="name">the name of a stemmer
/// </param>
public SnowballFilter(TokenStream in_Renamed, System.String name) : base(in_Renamed)
{
try
{
System.Type stemClass = System.Type.GetType("SF.Snowball.Ext." + name + "Stemmer");
stemmer = (SnowballProgram) System.Activator.CreateInstance(stemClass);
// why doesn't the SnowballProgram class have an (abstract?) stem method?
stemMethod = stemClass.GetMethod("Stem", (new System.Type[0] == null) ? new System.Type[0] : (System.Type[]) new System.Type[0]);
}
catch (System.Exception e)
{
throw new System.SystemException(e.ToString());
}
}
示例14: Init
public override void Init(Reactor reactor)
{
base.Init(reactor);
var cm = reactor.FindMethod(conditionMethod);
if(cm == null) {
Debug.LogError("Could not load condition method: " + conditionMethod);
} else {
if(cm.methodInfo.ReturnType == typeof(bool)) {
component = cm.component;
methodInfo = cm.methodInfo;
} else {
Debug.LogError("Condition method has invalid signature: " + conditionMethod);
}
}
}
示例15: ExecCmd
static ExecCmd()
{
{
// Runtime.exec(String[] cmdArr, String[] envArr, File currDir)
Type[] parameterTypes = new Type[] { typeof( string[] ), typeof( string[] ), typeof( FileInfo ) };
try
{
execMethod = System.Diagnostics.Process.GetCurrentProcess().GetType().GetMethod( "exec", (System.Type[])parameterTypes );
}
catch ( System.MethodAccessException e )
{
execMethod = null;
}
}
}