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


C# IMethodInfo.GetGenericArgsMapping方法代码示例

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


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

示例1: FuzzyMethod

        private FuzzyMethod(FuzzyType target, IMethodInfo runtimeMethod)
        {
            _method = runtimeMethod;

            var genericArgs = new List<FuzzyType>();
            foreach (var genericArg in _method.GetMethodGenericArguments())
                genericArgs.Add(FuzzyType.FromRuntimeType(genericArg));
            GenericArguments = genericArgs.AsReadOnly();

            Target = target;
            ReturnValue = FuzzyType.FromRuntimeType(_method.ReturnType);
            Args = _method.GetParameters()
                .Select(param => FuzzyType.FromRuntimeType(param.ParameterType))
                .ToArray();

            // establishing links between typedef generic args and method's generic args
            // read more comments at FuzzyType.GetFieldOrProperty
            // see also comments to ReflectionHelper.GetGenericArgsMapping

            foreach (var pair in _method.GetGenericArgsMapping())
            {
                var typeDefArg = SelectGenericArg(pair.Value);
                var publicTypePointArgs = SelectGenericArg(pair.Key);
                publicTypePointArgs.IsIdenticalTo(typeDefArg);
            }

            // SomeMoreStuffInferred handlers for children just escalate the event
            // no need to process it since everything necessary is already done by links
            //
            // upd. currently noone cares about this event from this very class, 
            // but imo it's still important to comply to FuzzyMetadata contract

            Target.SomeMoreStuffInferred += (o, e) => FireSomeMoreStuffInferred();
            ReturnValue.SomeMoreStuffInferred += (o, e) => FireSomeMoreStuffInferred();
            Args.ForEach(arg => arg.SomeMoreStuffInferred += (o, e) => FireSomeMoreStuffInferred());

            // Register typepoints for debug -> 0 downtime in release, but immensely useful in debug mode
            var methodBinding = target.DebuggableParents.OfType<FuzzyMethodBinding>().SingleOrDefault();
            if (methodBinding != null)
            {
                this.RegDebuggableParent(methodBinding).SetDesc("alt");
                ReturnValue.RegDebuggableParent(this).SetDesc("ret");
                Args.ForEach((arg, i) => arg.RegDebuggableParent(this).SetDesc("arg" + i));
            }
        }
开发者ID:xeno-by,项目名称:relinq,代码行数:45,代码来源:FuzzyMethod.cs


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