本文整理汇总了C#中MethodInfo类的典型用法代码示例。如果您正苦于以下问题:C# MethodInfo类的具体用法?C# MethodInfo怎么用?C# MethodInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodInfo类属于命名空间,在下文中一共展示了MethodInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IsComplementaryMethod
private static bool IsComplementaryMethod(MethodInfo actionMethod) {
var propertyPrefixes = new[] {
PrefixesAndRecognisedMethods.AutoCompletePrefix,
PrefixesAndRecognisedMethods.ModifyPrefix,
PrefixesAndRecognisedMethods.ClearPrefix,
PrefixesAndRecognisedMethods.ChoicesPrefix,
PrefixesAndRecognisedMethods.DefaultPrefix,
PrefixesAndRecognisedMethods.ValidatePrefix,
PrefixesAndRecognisedMethods.HidePrefix,
PrefixesAndRecognisedMethods.DisablePrefix
};
var actionPrefixes = new[] {
PrefixesAndRecognisedMethods.ValidatePrefix,
PrefixesAndRecognisedMethods.HidePrefix,
PrefixesAndRecognisedMethods.DisablePrefix
};
var parameterPrefixes = new[] {
PrefixesAndRecognisedMethods.AutoCompletePrefix,
PrefixesAndRecognisedMethods.ParameterChoicesPrefix,
PrefixesAndRecognisedMethods.ParameterDefaultPrefix,
PrefixesAndRecognisedMethods.ValidatePrefix
};
return propertyPrefixes.Any(prefix => IsComplementaryPropertyMethod(actionMethod, prefix)) ||
actionPrefixes.Any(prefix => IsComplementaryActionMethod(actionMethod, prefix)) ||
parameterPrefixes.Any(prefix => IsComplementaryParameterMethod(actionMethod, prefix));
}
开发者ID:radi4music,项目名称:NakedObjectsFramework,代码行数:30,代码来源:ComplementaryMethodsFilteringFacetFactory.cs
示例2: Execute
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
var xValue = aOpCode.StackPopTypes[0];
var xValueIsFloat = TypeIsFloat(xValue);
var xValueSize = SizeOfType(xValue);
if (xValueSize > 8)
{
//EmitNotImplementedException( Assembler, aServiceProvider, "Size '" + xSize.Size + "' not supported (add)", aCurrentLabel, aCurrentMethodInfo, aCurrentOffset, aNextLabel );
throw new NotImplementedException();
}
//TODO if on stack a float it is first truncated, http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.conv_r_un.aspx
if (!xValueIsFloat)
{
switch (xValueSize)
{
case 1:
case 2:
case 4:
new CPUx86.Mov { SourceReg = CPUx86.RegistersEnum.ESP, DestinationReg = CPUx86.RegistersEnum.EAX, SourceIsIndirect = true };
XS.SSE.ConvertSI2SS(XSRegisters.XMM0, XSRegisters.EAX);
XS.SSE.MoveSS(XSRegisters.ESP, XSRegisters.XMM0, destinationIsIndirect: true);
break;
case 8:
//XS.Add(XSRegisters.ESP, 4);
//break;
default:
//EmitNotImplementedException( Assembler, GetServiceProvider(), "Conv_I: SourceSize " + xSource + " not supported!", mCurLabel, mMethodInformation, mCurOffset, mNextLabel );
throw new NotImplementedException();
}
}
else
{
throw new NotImplementedException();
}
}
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:35,代码来源:Conv_R_Un.cs
示例3: Execute
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
DoNullReferenceCheck(Assembler, DebugEnabled, 0);
XS.Pop(XSRegisters.ECX);
new CPUx86.MoveSignExtend { DestinationReg = CPUx86.RegistersEnum.EAX, Size = 8, SourceReg = CPUx86.RegistersEnum.ECX, SourceIsIndirect = true };
XS.Push(XSRegisters.EAX);
}
开发者ID:Zino2201,项目名称:Cosmos,代码行数:7,代码来源:Ldind_I1.cs
示例4: CheckInvocationSafety
public static void CheckInvocationSafety(MethodInfo method, JSExpression[] argumentValues, TypeSystem typeSystem)
{
if (method.Metadata.HasAttribute("JSIL.Meta.JSAllowPackedArrayArgumentsAttribute"))
return;
TypeReference temp;
string[] argumentNames = GetPackedArrayArgumentNames(method, out temp);
for (var i = 0; i < method.Parameters.Length; i++) {
if (i >= argumentValues.Length)
continue;
var valueType = argumentValues[i].GetActualType(typeSystem);
if (!IsPackedArrayType(valueType)) {
if ((argumentNames != null) && argumentNames.Contains(method.Parameters[i].Name))
throw new ArgumentException(
"Invalid attempt to pass a normal array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
"This parameter must be a packed array."
);
} else {
if ((argumentNames == null) || !argumentNames.Contains(method.Parameters[i].Name))
throw new ArgumentException(
"Invalid attempt to pass a packed array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
"If this is intentional, annotate the method with the JSPackedArrayArguments attribute."
);
}
}
}
开发者ID:jean80it,项目名称:JSIL,代码行数:29,代码来源:PackedStructArray.cs
示例5: Execute
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
OpToken xToken = ( OpToken )aOpCode;
string xTokenAddress = null;
if (xToken.ValueIsType)
{
xTokenAddress = ILOp.GetTypeIDLabel(xToken.ValueType);
}
if (xToken.ValueIsField)
{
xTokenAddress= DataMember.GetStaticFieldName(xToken.ValueField);
}
if (String.IsNullOrEmpty(xTokenAddress))
{
throw new Exception("Ldtoken not implemented!");
}
//if( mType != null )
//{
// mTokenAddress = GetService<IMetaDataInfoService>().GetTypeIdLabel( mType );
//}
//XS.Push(xToken.Value);
XS.Push(xTokenAddress);
XS.Push(0);
}
开发者ID:fanoI,项目名称:Cosmos,代码行数:27,代码来源:Ldtoken.cs
示例6: RunTest
static bool RunTest (MethodInfo test)
{
Console.Write ("Running test {0, -25}", test.Name);
try {
Task t = test.Invoke (new Tester (), null) as Task;
if (!Task.WaitAll (new[] { t }, 1000)) {
Console.WriteLine ("FAILED (Timeout)");
return false;
}
var ti = t as Task<int>;
if (ti != null) {
if (ti.Result != 0) {
Console.WriteLine ("FAILED (Result={0})", ti.Result);
return false;
}
} else {
var tb = t as Task<bool>;
if (tb != null) {
if (!tb.Result) {
Console.WriteLine ("FAILED (Result={0})", tb.Result);
return false;
}
}
}
Console.WriteLine ("OK");
return true;
} catch (Exception e) {
Console.WriteLine ("FAILED");
Console.WriteLine (e.ToString ());
return false;
}
}
开发者ID:xzkmxd,项目名称:mono,代码行数:34,代码来源:test-async-16.cs
示例7: DefineMethod
public SymbolBinding DefineMethod(MethodInfo method)
{
var sb = _moduleCtx.DefineMethod(method);
ShiftIndex(ref sb);
return sb;
}
开发者ID:Shemetov,项目名称:OneScript,代码行数:7,代码来源:ModuleCompilerContext.cs
示例8: PostInstantiate
public void PostInstantiate(string entityName, Type persistentClass, ISet<Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType)
{
_entityName = entityName;
_persistentClass = persistentClass;
_interfaces = new Type[interfaces.Count];
interfaces.CopyTo(_interfaces, 0);
_getIdentifierMethod = getIdentifierMethod;
_setIdentifierMethod = setIdentifierMethod;
_componentIdType = componentIdType;
_isClassProxy = _interfaces.Length == 1;
_proxyKey = entityName;
if( _proxies.Contains(_proxyKey) )
{
_proxyType = _proxies[_proxyKey] as Type;
_log.DebugFormat("Using proxy type '{0}' for persistent class '{1}'", _proxyType.Name, _persistentClass.FullName);
}
else
{
string message = string.Format("No proxy type found for persistent class '{0}' using proxy key '{1}'", _persistentClass.FullName, _proxyKey);
_log.Error(message);
throw new HibernateException(message);
}
}
开发者ID:spib,项目名称:nhcontrib,代码行数:25,代码来源:CastleStaticProxyFactory.cs
示例9: Test
/// Create from funciton pointer
public Test(String name, MethodInfo fp, Object self)
{
this.error = null;
this.name = name;
this.fp = fp;
this.base_ = self;
}
开发者ID:shadowmint,项目名称:gulp-unity,代码行数:8,代码来源:Test.cs
示例10: MessageMappingMethodInvoker
public MessageMappingMethodInvoker(object obj, MethodInfo method)
{
AssertUtils.ArgumentNotNull(obj, "object must not be null");
AssertUtils.ArgumentNotNull(method, "method must not be null");
_obj = obj;
_methodResolver = new StaticHandlerMethodResolver(method);
}
开发者ID:rlxrlxrlx,项目名称:spring-net-integration,代码行数:7,代码来源:MessageMappingMethodInvoker.cs
示例11: ActionInvocationFacetViaMethod
public ActionInvocationFacetViaMethod(MethodInfo method, INakedObjectSpecification onType, INakedObjectSpecification returnType, IFacetHolder holder)
: base(holder) {
actionMethod = method;
paramCount = method.GetParameters().Length;
this.onType = onType;
this.returnType = returnType;
}
开发者ID:radi4music,项目名称:NakedObjectsFramework,代码行数:7,代码来源:ActionInvocationFacetViaMethod.cs
示例12: CompileCSharpImmediateSnippet
/// <summary>
/// Compiles a method body of C# script, wrapped in a basic void-returning method.
/// </summary>
/// <param name="methodText">The text of the script to place inside a method.</param>
/// <param name="errors">The compiler errors and warnings from compilation.</param>
/// <param name="methodIfSucceeded">The compiled method if compilation succeeded.</param>
/// <returns>True if compilation was a success, false otherwise.</returns>
public static bool CompileCSharpImmediateSnippet(string methodText, out CompilerErrorCollection errors, out MethodInfo methodIfSucceeded)
{
// wrapper text so we can compile a full type when given just the body of a method
string methodScriptWrapper = @"
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Linq;
public static class CodeSnippetWrapper
{{
public static void PerformAction()
{{
{0};
}}
}}";
// default method to null
methodIfSucceeded = null;
// compile the full script
Assembly assembly;
if (CompileCSharpScript(string.Format(methodScriptWrapper, methodText), out errors, out assembly))
{
// if compilation succeeded, we can use reflection to get the method and pass that back to the user
methodIfSucceeded = assembly.GetType("CodeSnippetWrapper").GetMethod("PerformAction", BindingFlags.Static | BindingFlags.Public);
return true;
}
// compilation failed, caller has the errors, return false
return false;
}
开发者ID:Danathus,项目名称:ggj2013-waves,代码行数:41,代码来源:NGCompiler.cs
示例13: Execute
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
var xType = aOpCode.StackPopTypes[0];
var xSize = SizeOfType(xType);
var xIsFloat = TypeIsFloat(xType);
DoExecute(xSize, xIsFloat);
}
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:7,代码来源:Add.cs
示例14: Execute
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
DoNullReferenceCheck(Assembler, DebugEnabled, 0);
new CPUx86.Pop { DestinationReg = CPUx86.Registers.ECX };
new CPUx86.MoveZeroExtend { DestinationReg = CPUx86.Registers.EAX, Size = 16, SourceReg = CPUx86.Registers.ECX, SourceIsIndirect = true };
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
}
开发者ID:Orvid,项目名称:Cosmos,代码行数:7,代码来源:Ldind_U2.cs
示例15: MemberSpecifiedDecorator
public MemberSpecifiedDecorator(MethodInfo getSpecified, MethodInfo setSpecified, IProtoSerializer tail)
: base(tail)
{
if (getSpecified == null && setSpecified == null) throw new InvalidOperationException();
this.getSpecified = getSpecified;
this.setSpecified = setSpecified;
}
开发者ID:Erguotou,项目名称:protobuf-net,代码行数:7,代码来源:MemberSpecifiedDecorator.cs
示例16: GetPackedArrayArgumentNames
public static string[] GetPackedArrayArgumentNames (MethodInfo method, out TypeReference packedArrayAttributeType) {
packedArrayAttributeType = null;
AttributeGroup packedArrayAttribute;
if (
(method != null) &&
((packedArrayAttribute = method.Metadata.GetAttribute("JSIL.Meta.JSPackedArrayArgumentsAttribute")) != null)
) {
var result = new List<string>();
foreach (var entry in packedArrayAttribute.Entries) {
packedArrayAttributeType = entry.Type;
var argumentNames = entry.Arguments[0].Value as IList<CustomAttributeArgument>;
if (argumentNames == null)
throw new ArgumentException("Arguments to JSPackedArrayArguments must be strings");
foreach (var attributeArgument in argumentNames) {
var argumentName = attributeArgument.Value as string;
if (argumentName == null)
throw new ArgumentException("Arguments to JSPackedArrayArguments must be strings");
result.Add(argumentName);
}
}
return result.ToArray();
}
return null;
}
开发者ID:GlennSandoval,项目名称:JSIL,代码行数:31,代码来源:PackedStructArray.cs
示例17: GetMethodLabel
public static string GetMethodLabel(MethodInfo aMethod) {
if (aMethod.PluggedMethod != null) {
return "PLUG_FOR___" + GetMethodLabel(aMethod.PluggedMethod.MethodBase);
} else {
return GetMethodLabel(aMethod.MethodBase);
}
}
开发者ID:Orvid,项目名称:Cosmos,代码行数:7,代码来源:ILOp.cs
示例18: Execute
public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
{
var xStackContent = aOpCode.StackPopTypes[0];
var xStackContentSize = SizeOfType(xStackContent);
string BaseLabel = GetLabel(aMethod, aOpCode) + ".";
DoExecute(xStackContentSize, BaseLabel);
}
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:7,代码来源:Mul_Ovf.cs
示例19: Process
public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
if ((method.ReturnType.IsPrimitive || TypeUtils.IsEnum(method.ReturnType)) && method.GetCustomAttribute<OptionallyAttribute>() != null) {
Log.Warn("Ignoring Optionally annotation on primitive parameter on " + method.ReflectedType + "." + method.Name);
return;
}
Process(method, specification);
}
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:7,代码来源:OptionalAnnotationFacetFactory.cs
示例20: Execute
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
var xStackContent = aOpCode.StackPopTypes[0];
var xStackContentSecond = aOpCode.StackPopTypes[1];
var xStackContentSize = SizeOfType(xStackContent);
var xStackContentSecondSize = SizeOfType(xStackContentSecond);
var xSize = Math.Max(xStackContentSize, xStackContentSecondSize);
if (ILOp.Align(xStackContentSize, 4u) != ILOp.Align(xStackContentSecondSize, 4u))
{
throw new NotSupportedException("Operands have different size!");
}
if (xSize > 8)
{
throw new NotImplementedException("StackSize>8 not supported");
}
if (xSize > 4)
{
// [ESP] is low part
// [ESP + 4] is high part
// [ESP + 8] is low part
// [ESP + 12] is high part
XS.Pop(XSRegisters.EAX);
XS.Pop(XSRegisters.EDX);
// [ESP] is low part
// [ESP + 4] is high part
XS.Or(XSRegisters.ESP, XSRegisters.EAX, destinationIsIndirect: true);
XS.Or(XSRegisters.ESP, XSRegisters.EDX, destinationDisplacement: 4);
}
else
{
XS.Pop(XSRegisters.EAX);
XS.Or(XSRegisters.ESP, XSRegisters.EAX, destinationIsIndirect: true);
}
}
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:35,代码来源:Or.cs
注:本文中的MethodInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论