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


C# MethodBase类代码示例

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


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

示例1: ComputeToString

        public static String ComputeToString(MethodBase contextMethod, RuntimeType[] methodTypeArguments, RuntimeParameterInfo[] runtimeParametersAndReturn)
        {
            StringBuilder sb = new StringBuilder(30);
            sb.Append(runtimeParametersAndReturn[0].ParameterTypeString);
            sb.Append(' ');
            sb.Append(contextMethod.Name);
            if (methodTypeArguments.Length != 0)
            {
                String sep = "";
                sb.Append('[');
                foreach (RuntimeType methodTypeArgument in methodTypeArguments)
                {
                    sb.Append(sep);
                    sep = ",";
                    String name = methodTypeArgument.InternalNameIfAvailable;
                    if (name == null)
                        name = ToStringUtils.UnavailableType;
                    sb.Append(methodTypeArgument.Name);
                }
                sb.Append(']');
            }
            sb.Append('(');
            sb.Append(ComputeParametersString(runtimeParametersAndReturn, 1));
            sb.Append(')');

            return sb.ToString();
        }
开发者ID:huamichaelchen,项目名称:corert,代码行数:27,代码来源:RuntimeMethodCommon.cs

示例2: Intercept

    public object Intercept(MethodBase decoratedMethod, MethodBase implementationMethod, object[] arguments)
    {
        if (this.implementationMethodTarget == null)
        {
            throw new InvalidOperationException("Something has gone seriously wrong with StaticProxy.Fody." +
                ".Initialize(implementationMethodTarget) must be called once before any .Intercept(..)");
        }

        // since we only support methods, not constructors, this is actually a MethodInfo
        var decoratedMethodInfo = (MethodInfo)decoratedMethod;
        
        ITargetInvocation targetInvocation = this.targetInvocationFactory.Create(this.implementationMethodTarget, implementationMethod);
        
        IInvocation invocation = this.invocationFactory
            .Create(targetInvocation, decoratedMethodInfo, arguments, this.interceptors.ToArray());

        invocation.Proceed();

        if (invocation.ReturnValue == null && !this.typeInformation.IsNullable(decoratedMethodInfo.ReturnType))
        {
            string message = string.Format(
                CultureInfo.InvariantCulture,
                "Method {0}.{1} has return type {2} which is a value type. After the invocation the invocation the return value was null. Please ensure that your interceptors call IInvocation.Proceed() or sets a valid IInvocation.ReturnValue.",
                this.implementationMethodTarget.GetType().FullName,
                decoratedMethodInfo,
                decoratedMethodInfo.ReturnType.FullName);
            throw new InvalidOperationException(message);
        }

        return invocation.ReturnValue;
    }
开发者ID:OmerRaviv,项目名称:StaticProxy.Fody,代码行数:31,代码来源:DynamicInterceptorManager.cs

示例3: BindToMethod

        public override MethodBase BindToMethod(
            BindingFlags bindingAttr,
            MethodBase[] match,
            ref object[] args,
            ParameterModifier[] modifiers,
            CultureInfo culture,
            string[] names,
            out object state)
        {
            if (match == null)
            {
                throw new ArgumentNullException("match");
            }
            // Arguments are not being reordered.
            state = null;
            // Find a parameter match and return the first method with
            // parameters that match the request.
            foreach (MethodBase mb in match)
            {
                ParameterInfo[] parameters = mb.GetParameters();

                if (ParametersMatch(parameters, args))
                {
                    return mb;
                }
            }
            return null;
        }
开发者ID:crankycoder,项目名称:PyInception,代码行数:28,代码来源:sample.cs

示例4: RuntimeFatMethodParameterInfo

 private RuntimeFatMethodParameterInfo(MethodBase member, MethodHandle methodHandle, int position, ParameterHandle parameterHandle, ReflectionDomain reflectionDomain, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
     : base(member, position, reflectionDomain, reader, typeHandle, typeContext)
 {
     _methodHandle = methodHandle;
     _parameterHandle = parameterHandle;
     _parameter = parameterHandle.GetParameter(reader);
 }
开发者ID:huamichaelchen,项目名称:corert,代码行数:7,代码来源:RuntimeFatMethodParameterInfo.cs

示例5: SelectMethod

        public override sealed MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
        {
            if (!((bindingAttr & ~SupportedBindingFlags) == 0) && modifiers == null)
                throw new NotImplementedException();

            return LimitedBinder.SelectMethod(match, types);
        }
开发者ID:tijoytom,项目名称:corert,代码行数:7,代码来源:DefaultBinder.cs

示例6: BindToMethod

 public override sealed MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
 {
     if (!((bindingAttr & ~SupportedBindingFlags) == 0) && modifiers == null && culture == null && names == null)
         throw new NotImplementedException();
     state = null;
     return LimitedBinder.BindToMethod(match, ref args);
 }
开发者ID:tijoytom,项目名称:corert,代码行数:7,代码来源:DefaultBinder.cs

示例7: RuntimeMethodParameterInfo

 protected RuntimeMethodParameterInfo(MethodBase member, int position, ReflectionDomain reflectionDomain, MetadataReader reader, Handle typeHandle, TypeContext typeContext)
     : base(member, position)
 {
     _reflectionDomain = reflectionDomain;
     Reader = reader;
     _typeHandle = typeHandle;
     _typeContext = typeContext;
 }
开发者ID:huamichaelchen,项目名称:corert,代码行数:8,代码来源:RuntimeMethodParameterInfo.cs

示例8: Init

 public override void Init(object instance, MethodBase method, object[] args)
 {
     _instance = instance;
     _method = method;
     _args = args;
     if (method.Name == "ApiHandler") _logoType = "接口通道ApiHandler";
     else if (method.Name == "InfoApiHandler") _logoType = "接口通道InfoApiHandler";
     else if (method.Name == "StreamApiHandler") _logoType = "接口通道StreamApiHandler";
 }
开发者ID:waitaction,项目名称:RESTfulFramework.NET,代码行数:9,代码来源:RecordLog.cs

示例9: GetParameterTypes

 // returns array of the types of the parameters of the method specified by methodinfo
 public static Type[] GetParameterTypes( MethodBase methodbase )
 {
     ParameterInfo[] parameterinfos = methodbase.GetParameters();
     Type[] paramtypes = new Type[ parameterinfos.GetUpperBound(0) + 1 ];
     for( int i = 0; i < parameterinfos.GetUpperBound(0) + 1; i ++ )
     {
         paramtypes[i] = parameterinfos[i].ParameterType;
     }
     return paramtypes;
 }
开发者ID:achoum,项目名称:spring,代码行数:11,代码来源:AbicWrapperGenerator.cs

示例10: GetFullNameForStackTrace

		public static void GetFullNameForStackTrace (StringBuilder sb, MethodBase mi)
		{
			var declaringType = mi.DeclaringType;
			if (declaringType.IsGenericType && !declaringType.IsGenericTypeDefinition)
				declaringType = declaringType.GetGenericTypeDefinition ();

			// Get generic definition
			var bindingflags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
			foreach (var m in declaringType.GetMethods (bindingflags)) {
				if (m.MetadataToken == mi.MetadataToken) {
					mi = m;
					break;
				}
			}

			sb.Append (declaringType.ToString ());

			sb.Append (".");
			sb.Append (mi.Name);

			if (mi.IsGenericMethod) {
				Type[] gen_params = mi.GetGenericArguments ();
				sb.Append ("[");
				for (int j = 0; j < gen_params.Length; j++) {
					if (j > 0)
						sb.Append (",");
					sb.Append (gen_params [j].Name);
				}
				sb.Append ("]");
			}

			ParameterInfo[] p = mi.GetParameters ();

			sb.Append (" (");
			for (int i = 0; i < p.Length; ++i) {
				if (i > 0)
					sb.Append (", ");

				Type pt = p[i].ParameterType;
				if (pt.IsGenericType && ! pt.IsGenericTypeDefinition)
					pt = pt.GetGenericTypeDefinition ();

				sb.Append (pt.ToString());

				if (p [i].Name != null) {
					sb.Append (" ");
					sb.Append (p [i].Name);
				}
			}
			sb.Append (")");
		}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:51,代码来源:StackTraceHelper.cs

示例11: ParameterBuilder

	// Constructor.
	internal ParameterBuilder(TypeBuilder type, MethodBase method,
							  int position, ParameterAttributes attributes,
							  String strParamName)
			{
				// Initialize the internal state.
				this.type = type;
				this.method = method;

				// Register this item to be detached later.
				type.module.assembly.AddDetach(this);

				// Create the parameter.
				lock(typeof(AssemblyBuilder))
				{
					this.privateData = ClrParameterCreate
						(((IClrProgramItem)method).ClrHandle,
						 position, attributes, strParamName);
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:20,代码来源:ParameterBuilder.cs

示例12: GetVTableMethods

 MethodBase[] GetVTableMethods(VTableFixups fixups)
 {
     var methods = new MethodBase[fixups.Count];
     byte[] buf = new byte[8];
     int fixuprva = fixups.RVA;
     for (int i = 0; i < fixups.Count; i++)
     {
         module.__ReadDataFromRVA(fixuprva, buf, 0, 4);
         methods[i] = module.ResolveMethod(BitConverter.ToInt32(buf, 0));
         if ((fixups.Type & COR_VTABLE_32BIT) != 0)
         {
             fixuprva += 4;
         }
         if ((fixups.Type & COR_VTABLE_64BIT) != 0)
         {
             fixuprva += 8;
         }
     }
     return methods;
 }
开发者ID:jfrijters,项目名称:ikdasm,代码行数:20,代码来源:VTableFixups.cs

示例13: Log

 /// <summary>
 /// Used by MethodTimer.
 /// </summary>
 /// <param name="methodBase"></param>
 /// <param name="milliseconds"></param>
 public static void Log(MethodBase methodBase, long milliseconds)
 {
     Log(methodBase.DeclaringType, methodBase.Name, milliseconds);
 }
开发者ID:WildGums,项目名称:Orc.LicenseManager,代码行数:9,代码来源:MethodTimeLogger.cs

示例14: ApplyAttributes

		// Define each type attribute (in/out/ref) and
		// the argument names.
		public void ApplyAttributes (IMemberContext mc, MethodBase builder)
		{
			if (Count == 0)
				return;

			MethodBuilder mb = builder as MethodBuilder;
			ConstructorBuilder cb = builder as ConstructorBuilder;
			var pa = mc.Module.PredefinedAttributes;

			for (int i = 0; i < Count; i++) {
				this [i].ApplyAttributes (mb, cb, i + 1, pa);
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:15,代码来源:parameter.cs

示例15: GetMetaInfo

		public MethodBase GetMetaInfo ()
		{
			//
			// inflatedMetaInfo is extra field needed for cases where we
			// inflate method but another nested type can later inflate
			// again (the cache would be build with inflated metaInfo) and
			// TypeBuilder can work with method definitions only
			//
			if (inflatedMetaInfo == null) {
				if ((state & StateFlags.PendingMetaInflate) != 0) {
					var dt_meta = DeclaringType.GetMetaInfo ();

					if (DeclaringType.IsTypeBuilder) {
						if (IsConstructor)
							inflatedMetaInfo = TypeBuilder.GetConstructor (dt_meta, (ConstructorInfo) MemberDefinition.Metadata);
						else
							inflatedMetaInfo = TypeBuilder.GetMethod (dt_meta, (MethodInfo) MemberDefinition.Metadata);
					} else {
#if STATIC
						// it should not be reached
						throw new NotImplementedException ();
#else
						inflatedMetaInfo = MethodInfo.GetMethodFromHandle (MemberDefinition.Metadata.MethodHandle, dt_meta.TypeHandle);
#endif
					}

					state &= ~StateFlags.PendingMetaInflate;
				} else {
					inflatedMetaInfo = MemberDefinition.Metadata;
				}
			}

			if ((state & StateFlags.PendingMakeMethod) != 0) {
				var sre_targs = new MetaType[targs.Length];
				for (int i = 0; i < sre_targs.Length; ++i)
					sre_targs[i] = targs[i].GetMetaInfo ();

				inflatedMetaInfo = ((MethodInfo) inflatedMetaInfo).MakeGenericMethod (sre_targs);
				state &= ~StateFlags.PendingMakeMethod;
			}

			return inflatedMetaInfo;
		}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:43,代码来源:method.cs


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