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


C# MethodInfo.GetBaseDefinition方法代码示例

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


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

示例1: GetProperty

 private static PropertyInfo GetProperty(MethodInfo propertyGetterOrSetter)
 {
     return
         (from property in propertyGetterOrSetter.DeclaringType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
          let getMethod = property.GetGetMethod(true)
          let setMethod = property.GetSetMethod(true)
          where (getMethod != null && getMethod.GetBaseDefinition().Equals(propertyGetterOrSetter.GetBaseDefinition()))
              || (setMethod != null && setMethod.GetBaseDefinition().Equals(propertyGetterOrSetter.GetBaseDefinition()))
          select property).Single();
 }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:10,代码来源:FakeManager.PropertyBehaviorRule.cs

示例2: CreatePipeline

        ///// <summary>
        ///// 创建并返回当前方法的拦截器管道
        ///// </summary>
        //public InterceptorPipeline CreatePipeline(MethodInfo method, Func<IEnumerable<IInterceptor>> getInterceptors)
        //{
        //    var key = InterceptorPipelineKey.ForMethod(method);
        //    if (pipelines.ContainsKey(key))
        //        return pipelines[key];
        //    if (method.GetBaseDefinition() == method)
        //        return pipelines[key] = new InterceptorPipeline(getInterceptors());
        //    return pipelines[key] = CreatePipeline(method.GetBaseDefinition(), getInterceptors);
        //}
        /// <summary>
        /// 创建并返回当前方法的拦截器管道
        /// </summary>
        public InterceptorPipeline CreatePipeline(MethodInfo method, Func<MethodInfo, IEnumerable<IInterceptor>> getInterceptors)
        {
            var key = InterceptorPipelineKey.ForMethod(method);

            if(pipelines.ContainsKey(key))
                return pipelines[key];

            if(method.GetBaseDefinition() == method)
                return pipelines[key] = new InterceptorPipeline(getInterceptors(method));

            return pipelines[key] = CreatePipeline(method.GetBaseDefinition(), getInterceptors);
        }
开发者ID:imyounghan,项目名称:thinklib,代码行数:27,代码来源:InterceptorPipelineManager.cs

示例3: NativeMethodBuilder

        internal NativeMethodBuilder(MethodInfo minfo)
        {
            ExportAttribute ea = (ExportAttribute) Attribute.GetCustomAttribute (minfo.GetBaseDefinition (), typeof (ExportAttribute));

            if (ea == null)
                throw new ArgumentException ("MethodInfo does not have a export attribute");

            parms = minfo.GetParameters ();

            rettype = ConvertReturnType (minfo.ReturnType);
            // FIXME: We should detect if this is in a bound assembly or not and only alloc if needed
            Selector = new Selector (ea.Selector ?? minfo.Name, true).Handle;
            Signature = string.Format ("{0}@:", TypeConverter.ToNative (rettype));
            ParameterTypes = new Type [2 + parms.Length];

            ParameterTypes [0] = typeof (NSObject);
            ParameterTypes [1] = typeof (Selector);

            for (int i = 0; i < parms.Length; i++) {
                if (parms [i].ParameterType.IsByRef && (parms[i].ParameterType.GetElementType ().IsSubclassOf (typeof (NSObject)) || parms[i].ParameterType.GetElementType () == typeof (NSObject)))
                    ParameterTypes [i + 2] = typeof (IntPtr).MakeByRefType ();
                else
                    ParameterTypes [i + 2] = parms [i].ParameterType;
                // The TypeConverter will emit a ^@ for a byref type that is a NSObject or NSObject subclass in this case
                // If we passed the ParameterTypes [i+2] as would be more logical we would emit a ^^v for that case, which
                // while currently acceptible isn't representative of what obj-c wants.
                Signature += TypeConverter.ToNative (parms [i].ParameterType);
            }

            DelegateType = CreateDelegateType (rettype, ParameterTypes);

            this.minfo = minfo;
        }
开发者ID:sichy,项目名称:monomac,代码行数:33,代码来源:NativeMethodBuilder.cs

示例4: IsValidActionMethod

        private bool IsValidActionMethod(MethodInfo methodInfo, bool stripInfrastructureMethods)
        {
            if (methodInfo.IsSpecialName)
            {
                // not a normal method, e.g. a constructor or an event
                return false;
            }

            if (methodInfo.GetBaseDefinition().DeclaringType.IsAssignableFrom(typeof(AsyncController)))
            {
                // is a method on Object, ControllerBase, Controller, or AsyncController
                return false;
            }

            if (stripInfrastructureMethods)
            {
                if (IsCompletedSuffixedMethod(methodInfo))
                {
                    // do not match FooCompleted() methods, as these are infrastructure methods
                    return false;
                }
            }

            return true;
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:25,代码来源:AsyncActionMethodSelector.cs

示例5: HasSameBaseMethod

        private static bool HasSameBaseMethod(MethodInfo first, MethodInfo second)
        {
            var baseOfFirst = first.GetBaseDefinition();
            var baseOfSecond = second.GetBaseDefinition();

            return IsSameMethod(baseOfFirst, baseOfSecond);
        }
开发者ID:NameOfTheDragon,项目名称:FakeItEasy,代码行数:7,代码来源:MethodInfoManager.cs

示例6: GetRouteAttributes

        public override IEnumerable<IRouteAttribute> GetRouteAttributes(MethodInfo actionMethod)
        {
            // Logic from ApiControllerActionSelector

            if (actionMethod.IsSpecialName)
            {
                // not a normal method, e.g. a constructor or an event
                yield break;
            }

            if (actionMethod.GetBaseDefinition().SafeGet(x => x.DeclaringType).IsAssignableFrom(typeof(ApiController)))
            {
                // is a method on Object, IHttpController, ApiController
                yield break;
            }

            foreach (var c in Conventions)
            {
                if (actionMethod.Name.StartsWith(c.HttpMethod.Method, StringComparison.OrdinalIgnoreCase))
                {
                    var requiresId = !string.IsNullOrEmpty(c.Url);

                    if (!_alreadyUsed.Contains(c))
                    {
                        // Check first parameter, if it requires ID
                        if (!requiresId || (actionMethod.GetParameters().Length > 0 && actionMethod.GetParameters()[0].Name.Equals("id", StringComparison.OrdinalIgnoreCase)))
                        {
                            yield return BuildRouteAttribute(c);

                            _alreadyUsed.Add(c);
                        }
                    }
                }
            }
        }
开发者ID:Cefa68000,项目名称:AttributeRouting,代码行数:35,代码来源:DefaultHttpRouteConventionAttribute.cs

示例7: NativeMethodBuilder

		internal NativeMethodBuilder (MethodInfo minfo) {
			ExportAttribute ea = (ExportAttribute) Attribute.GetCustomAttribute (minfo.GetBaseDefinition (), typeof (ExportAttribute));
			ParameterInfo [] parms = minfo.GetParameters ();

			if (ea == null)
				throw new ArgumentException ("MethodInfo does not have a export attribute");

			rettype = ConvertReturnType (minfo.ReturnType);
			// FIXME: We should detect if this is in a bound assembly or not and only alloc if needed
			Selector = new Selector (ea.Selector ?? minfo.Name, true).Handle;
			Signature = string.Format ("{0}@:", TypeConverter.ToNative (rettype));
			ParameterTypes = new Type [2 + parms.Length];

			ParameterTypes [0] = typeof (NSObject);
			ParameterTypes [1] = typeof (Selector);

			for (int i = 0; i < parms.Length; i++) {
				if (parms [i].ParameterType.IsByRef && (parms[i].ParameterType.IsSubclassOf (typeof (NSObject)) || parms[i].ParameterType == typeof (NSObject)))
					ParameterTypes [i + 2] = typeof (IntPtr).MakeByRefType ();
				else
					ParameterTypes [i + 2] = parms [i].ParameterType;
				Signature += TypeConverter.ToNative (parms [i].ParameterType);
			}
			
			DelegateType = CreateDelegateType (rettype, ParameterTypes);

			this.minfo = minfo;
		}
开发者ID:kangaroo,项目名称:monomac,代码行数:28,代码来源:NativeMethodBuilder.cs

示例8: Classify

 void Classify(MethodInfo method, Dictionary<MethodInfo, MethodInfo> virtuals)
 {
     if(method.IsVirtual) {
         virtuals[method.GetBaseDefinition()] = method;
         return;
     }
     classifier.Classify(method);
 }
开发者ID:drunkcod,项目名称:Cone,代码行数:8,代码来源:ConeFixtureSetup.cs

示例9: GetBaseDefinition

        private static MethodInfo GetBaseDefinition(MethodInfo method)
        {
            if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
            {
                method = method.GetGenericMethodDefinition();
            }

            return method.GetBaseDefinition();
        }
开发者ID:bluePlayer,项目名称:FakeItEasy,代码行数:9,代码来源:MethodInfoManager.cs

示例10: IsActionMethod

		protected virtual bool IsActionMethod(MethodInfo method)
        {
            Precondition.Require(method, () => Error.ArgumentNull("method"));

            if (method.IsDefined(typeof(IgnoreActionAttribute), false))
                return false;

            return (!method.IsAbstract && !method.IsSpecialName && !method.ContainsGenericParameters &&
                typeof(Controller).IsAssignableFrom(method.GetBaseDefinition().DeclaringType));
        }
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:10,代码来源:ActionMethodSelector.cs

示例11: IsActionMethod

		protected virtual bool IsActionMethod(MethodInfo method, 
			bool ignoreInfrastructureMethods)
		{
			if (method.GetBaseDefinition().DeclaringType.IsAssignableFrom(typeof(AsyncController)))
				return false;

			if (ignoreInfrastructureMethods && IsCompletedSuffixedMethod(method))
				return false;
			
			return true;
		}
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:11,代码来源:AsyncActionMethodSelector.cs

示例12: GetItem

        protected virtual IMethodCallTranslator GetItem(MethodInfo key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            IMethodCallTranslator translator;
            if (Registry.TryGetValue(key, out translator))
            {
                return translator;
            }

            if (key.IsGenericMethod && !key.IsGenericMethodDefinition)
            {
                if (Registry.TryGetValue(key.GetGenericMethodDefinition(), out translator))
                {
                    return translator;
                }
            }

            // Check if the generic form of the declaring type matches
            translator = GetItemFromGenericType(key);
            if (translator != null)
            {
                return translator;
            }

            // Check any interfaces that may have a matching method
            translator = GetItemFromInterfaces(key);
            if (translator != null)
            {
                return translator;
            }

            // Finally, check base method if this is a virtual method
            var baseMethod = key.GetBaseDefinition();
            if ((baseMethod != null) && (baseMethod != key))
            {
                return GetItem(baseMethod);
            }

            // No match found
            return null;
        }
开发者ID:sebgriffiths,项目名称:Linq2Couchbase,代码行数:45,代码来源:DefaultMethodCallTranslatorProvider.cs

示例13: MethodInf

 public MethodInf(MethodInfo method, IFieldHandlerFactory fieldHandlerFactory)
 {
     MethodInfo = method;
     _name = method.Name;
     foreach (var itf in GetInterfacesForMethod(method.DeclaringType, method.GetBaseDefinition()))
     {
         _ifaceName = itf.Name;
         break;
     }
     var syncReturnType = method.ReturnType.UnwrapTask();
     if (syncReturnType != typeof(void))
         _resultFieldHandler = fieldHandlerFactory.CreateFromType(syncReturnType, FieldHandlerOptions.None);
     var parameterInfos = method.GetParameters();
     _parameters = new ParameterInf[parameterInfos.Length];
     for (int i = 0; i < parameterInfos.Length; i++)
     {
         _parameters[i] = new ParameterInf(parameterInfos[i], fieldHandlerFactory);
     }
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:19,代码来源:MethodInf.cs

示例14: CreatePipeline

        private HandlerPipeline CreatePipeline(MethodInfo method, IEnumerable<ICallHandler> handlers)
        {
            HandlerPipelineKey key = HandlerPipelineKey.ForMethod(method);
            if (pipelines.ContainsKey(key))
            {
                return pipelines[key];
            }

            if (method.GetBaseDefinition() == method)
            {
                pipelines[key] = new HandlerPipeline(handlers);
                return pipelines[key];
            }

            var basePipeline = CreatePipeline(method.GetBaseDefinition(), handlers);
            pipelines[key] = basePipeline;
            return basePipeline;
            
        }
开发者ID:shhyder,项目名称:MapApplication,代码行数:19,代码来源:PipelineManager.cs

示例15: MethodAddVirtual

        public MethodAddVirtual(Type modifyingType, MethodInfo virtual_method, MethodInfo custom_method, MethodHookType type = MethodHookType.RunAfter, MethodHookFlags flags = MethodHookFlags.None)
            : base(virtual_method, custom_method, type, flags)
        {
            ModifyingType = modifyingType;
            if (ModifyingType == null)
                throw new ArgumentException("No target type specified!");
            if (!virtual_method.DeclaringType.IsAssignableFrom(modifyingType))
                throw new ArgumentException("Given Type [" + ModifyingType.FullName + "] is not a child of target [" + virtual_method.DeclaringType + "]!");
            base.Validate_4_ParameterLayout();

            if (modifyingType
                .GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
                .Select(m => m.GetBaseDefinition())
                .Contains(virtual_method.GetBaseDefinition()))
            {
                if (virtual_method.DeclaringType == modifyingType)
                {
                    throw new ArgumentException("Can't add a new virtual override method [" + virtual_method.Name + "]. Type [" + modifyingType.FullName + "] appears to already have such one. May just use a hook?");
                }
            }
            else
            {
                throw new NotImplementedException("This part hopefully isn't necessary ever :p");
                /*
                 * MAKE SURE THAT WE HAVE THE REF TO ACTUAL BASE FUNCTION WE MODIFY ... required to to base.ourfunc();
                 *
                var tMeth = modifyingType
                    .GetMethods();
                var virtParamTypes = virtual_method.GetParameters().Select(p => p.ParameterType);
                var similarMethods = modifyingType
                    .GetMethods()
                    .Where(f => f.Name == virtual_method.Name
                        && f.ReturnType == virtual_method.ReturnType
                        && f.IsStatic == virtual_method.IsStatic
                        && f.GetParameters().Select(p => p.ParameterType).SequenceEqual(virtParamTypes)
                    );
                if (similarMethods.Count() > 0)
                    throw new ArgumentException("Can't add a new virtual override method [" + virtual_method.Name + "]. Type [" + modifyingType.FullName + "] appears to already have such one. May just use a hook?");
                */
            }
        }
开发者ID:Gnomodia,项目名称:Gnomodia,代码行数:41,代码来源:MethodAddVirtual.cs


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