当前位置: 首页>>代码示例>>C#>>正文


C# Reflection.MethodBase类代码示例

本文整理汇总了C#中System.Reflection.MethodBase的典型用法代码示例。如果您正苦于以下问题:C# MethodBase类的具体用法?C# MethodBase怎么用?C# MethodBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MethodBase类属于System.Reflection命名空间,在下文中一共展示了MethodBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FormatMethod

 protected virtual string FormatMethod(MethodBase method)
 {
     var sb = new StringBuilder();
     if (method.DeclaringType != null)
     {
         sb.Append(method.DeclaringType.FullName);
         sb.Append(".");
     }
     sb.Append(method.Name);
     if (method.IsGenericMethod)
     {
         sb.Append("<");
         sb.Append(string.Join(", ", method.GetGenericArguments().Select(t => t.Name)));
         sb.Append(">");
     }
     sb.Append("(");
     var f = false;
     foreach (var p in method.GetParameters())
     {
         if (f) sb.Append(", ");
         else f = true;
         sb.Append(p.ParameterType.Name);
         sb.Append(' ');
         sb.Append(p.Name);
     }
     sb.Append(")");
     return sb.ToString();
 }
开发者ID:darilek,项目名称:dotvvm,代码行数:28,代码来源:ExceptionSectionFormatter.cs

示例2: Action

		public override object Action(object target, MethodBase method, object[] parameters, object result)
		{
			string namePrincipal = Thread.CurrentPrincipal.Identity.Name;
			if (namePrincipal == string.Empty)
			{
				namePrincipal = "Anonymous User";
			}

			namePrincipal = "User: " + namePrincipal;

			string text = "Assambly: " + target.ToString() + "\nMethod: " + method.Name;

			string content = Helper.ReadFile(_pathInternal);

			try
			{
				Helper.SaveToFile(namePrincipal, text, content, _pathInternal);
			}
			catch
			{
				throw;
			}

			return null;
		}
开发者ID:treytomes,项目名称:ILExperiments,代码行数:25,代码来源:LoggerToFile.cs

示例3: ReflectedMethod

 public ReflectedMethod(Identifier name, MethodBase method, Type targetType)
     : base(name, null, method, targetType)
 {
     DeclaringName = method.DeclaringType != targetType
         ? IdentifierFor.Method(method, method.DeclaringType)
         : name;
 }
开发者ID:cdrnet,项目名称:docu,代码行数:7,代码来源:ReflectedMethod.cs

示例4: MethodTracerItem

 /// <summary>
 /// Constructor.
 /// </summary>
 public MethodTracerItem(TypeEnum itemType, TracerItem.PriorityEnum priority, string message, MethodBase methodInfo, string threadName, string threadId)
     : base(itemType, priority, message)
 {
     _methodBase = methodInfo;
     _threadId = threadId;
     _threadName = threadName;
 }
开发者ID:redrhino,项目名称:DotNetConnectTerminal,代码行数:10,代码来源:MethodTracerItem.cs

示例5: CompileTimeValidate

        // Validate the attribute usage.
        public override bool CompileTimeValidate( MethodBase method )
        {
            // Don't apply to constructors.
            if ( method is ConstructorInfo )
            {
                Message.Write( SeverityType.Error, "CX0001", "Cannot cache constructors." );
                return false;
            }

            MethodInfo methodInfo = (MethodInfo) method;

            // Don't apply to void methods.
            if ( methodInfo.ReturnType.Name == "Void" )
            {
                Message.Write( SeverityType.Error, "CX0002", "Cannot cache void methods." );
                return false;
            }

            // Does not support out parameters.
            ParameterInfo[] parameters = method.GetParameters();
            for ( int i = 0; i < parameters.Length; i++ )
            {
                if ( parameters[i].IsOut )
                {
                    Message.Write( SeverityType.Error, "CX0003", "Cannot cache methods with return values." );
                    return false;
                }
            }

            return true;
        }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:32,代码来源:CacheAttribute.cs

示例6: IsStatic

		//===========================================================================================
		private bool IsStatic(MethodBase[] methods)
		{
			if (methods.Length != 1)
				return false;

			return IsStatic(methods[0]);
		}
开发者ID:dlemstra,项目名称:GraphicsMagick.NET,代码行数:8,代码来源:ExecuteCodeGenerator.cs

示例7: InitialiseProperties

        public void InitialiseProperties(
            Type classUnderTest,
            object instanceUnderTest,
            MethodBase methodUnderTest,
            object[] parameters,
            string nullParameter,
            int nullIndex,
            IExecutionSetup executionSetup)
        {
            // Act
            var sut = new MethodData(
                classUnderTest,
                instanceUnderTest,
                methodUnderTest,
                parameters,
                nullParameter,
                nullIndex,
                executionSetup);

            // Assert
            Assert.Same(classUnderTest, sut.ClassUnderTest);
            Assert.Equal(instanceUnderTest, sut.InstanceUnderTest);
            Assert.Same(methodUnderTest, sut.MethodUnderTest);
            Assert.Same(parameters, sut.Parameters);
            Assert.Same(nullParameter, sut.NullParameter);
            Assert.Equal(nullIndex, sut.NullIndex);
            Assert.Same(executionSetup, sut.ExecutionSetup);
        }
开发者ID:AutoTestNET,项目名称:AutoTest.ArgumentNullException,代码行数:28,代码来源:MethodDataShould.cs

示例8: MonoMethodMessage

		public MonoMethodMessage (MethodBase method, object [] out_args)
		{
			if (method != null)
				InitMessage ((MonoMethod)method, out_args);
			else
				args = null;
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:7,代码来源:MonoMethodMessage.cs

示例9: GetNumberOfStackPushes

 public override int GetNumberOfStackPushes(MethodBase aMethod)
 {
   switch (OpCode)
   {
     case Code.Initobj:
       return 0;
     case Code.Ldelema:
       return 1;
     case Code.Newarr:
       return 1;
     case Code.Box:
       return 1;
     case Code.Stelem:
       return 0;
     case Code.Ldelem:
       return 1;
     case Code.Isinst:
       return 1;
     case Code.Castclass:
       return 1;
     case Code.Constrained:
       return 0;
     case Code.Unbox_Any:
       return 1;
     case Code.Unbox:
       return 1;
     case Code.Stobj:
       return 0;
     case Code.Ldobj:
       return 1;
     default:
       throw new NotImplementedException("OpCode '" + OpCode + "' not implemented!");
   }
 }
开发者ID:bing2514,项目名称:Cosmos,代码行数:34,代码来源:OpType.cs

示例10: TypeActivationContext

 /// <summary>
 /// Initializes a new instance of the MethodActivationContext class.
 /// </summary>
 /// <param name="target">The object instance that initiated the activation request.</param>
 /// <param name="targetMethod">The method where the activation was invoked.</param>
 /// <param name="concreteType">The type to be constructed.</param>
 /// <param name="additionalArguments">The additional arguments that will be passed to the constructor.</param>
 public TypeActivationContext(object target, MethodBase targetMethod,
     Type concreteType, object[] additionalArguments)
     : base(concreteType, additionalArguments)
 {
     Target = target;
     TargetMethod = targetMethod;
 }
开发者ID:slieser,项目名称:LinFu,代码行数:14,代码来源:TypeActivationContext.cs

示例11: FromMethod

 /// <summary>
 /// Creates a REST call from a given method.
 /// If the method has no marker, a null is returned
 /// </summary>
 /// <param name="methodBase">The method base.</param>
 /// <returns></returns>
 public static RestCall FromMethod(MethodBase methodBase)
 {
     var httpGet = methodBase.GetCustomAttribute<HttpGetAttribute>();
     if (httpGet != null)
         return new RestCall("GET", httpGet.UriTemplate);
     return null;
 }
开发者ID:systemmetaphor,项目名称:BlueDwarf,代码行数:13,代码来源:RestCall.cs

示例12: Action

		public override object Action(object target, MethodBase method, object[] parameters, object result)
		{
			string namePrincipal = Thread.CurrentPrincipal.Identity.Name;
			if (namePrincipal == string.Empty)
			{
				namePrincipal = "Anonymous User";
			}

			namePrincipal = "User: " + namePrincipal;

			string text = new StringBuilder()
				.AppendFormat("Assambly: {0}", target).AppendLine()
				.AppendFormat("Method: {0}", method.Name).AppendLine().AppendLine()
				.AppendFormat("InnerException: {0}" + (result as Exception).InnerException)
				.ToString();

			string content = Helper.ReadFile(_pathInternal);

			try
			{
				Helper.SaveToFile(namePrincipal, text, content, _pathInternal);
			}
			catch
			{
				throw;
			}

			return null;
		}
开发者ID:treytomes,项目名称:ILExperiments,代码行数:29,代码来源:LogExceptionToFile.cs

示例13: CreateLocalsForByRefParams

 protected byte CreateLocalsForByRefParams(byte paramArrayIndex, MethodBase invocationInfo)
 {
     byte numberOfByRefParams = 0;
     ParameterInfo[] parameters = invocationInfo.GetParameters();
     for (int i = 0; i < ParameterTypes.Length; i++)
     {
         Type paramType = ParameterTypes[i];
         if (paramType.IsByRef)
         {
             Type type = paramType.GetElementType();
             Emit.DeclareLocal(type);
             if (!parameters[i].IsOut) // no initialization necessary is 'out' parameter
             {
                 Emit.ldarg(paramArrayIndex)
                     .ldc_i4(i)
                     .ldelem_ref
                     .CastFromObject(type)
                     .stloc(numberOfByRefParams)
                     .end();
             }
             numberOfByRefParams++;
         }
     }
     return numberOfByRefParams;
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:25,代码来源:InvocationEmitter.cs

示例14: ExceptionThrowingTest

 public ExceptionThrowingTest(TimeSpan runningTime, MethodBase method, Exception thrownException, IObjectInstance instance = null,
                              IEnumerable<IObjectInstance> arguments = null)
     : base(runningTime, method, instance, arguments)
 {
     if (thrownException == null) throw new ArgumentNullException("thrownException");
     Exception = thrownException;
 }
开发者ID:eneiand,项目名称:Baseline,代码行数:7,代码来源:ExceptionThrowingTest.cs

示例15: Method

 internal Method(MethodBase methodBase, UtilityFactory factory)
 {
     if (methodBase == null)
         throw new ArgumentNullException("methodBase");
     this.methodBase = methodBase;
     this.factory = factory;
 }
开发者ID:Stewartarmbrecht,项目名称:xBDD,代码行数:7,代码来源:Method.cs


注:本文中的System.Reflection.MethodBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。