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


C# TypeReference.EnumResolvedMethods方法代码示例

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


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

示例1: FindJsMember

 private static MethodReference FindJsMember(MethodReference mRef, TypeReference mappedTRef) {
     Func<IEnumerable<CustomAttribute>, string, bool> isMatch = (attrs, mName) => {
         return attrs.Any(a => {
             string aMethodName = null;
             TypeReference aReturnType = null;
             IEnumerable<TypeReference> aParameterTypes = null;
             bool? isStatic = null;
             var numArgs = a.ConstructorArguments.Count;
             var ctorArgs = a.ConstructorArguments;
             if (numArgs == 0 || (numArgs == 1 && ctorArgs[0].Type.IsString())) {
                 // Do nothing
             } else if (numArgs == 2) {
                 aReturnType = (TypeReference)ctorArgs[0].Value;
                 aParameterTypes = ((IEnumerable<CustomAttributeArgument>)ctorArgs[1].Value).Select(x => (TypeReference)x.Value).ToArray();
             } else if (numArgs == 3) {
                 aMethodName = (string)ctorArgs[0].Value;
                 aReturnType = (TypeReference)ctorArgs[1].Value;
                 aParameterTypes = ((IEnumerable<CustomAttributeArgument>)ctorArgs[2].Value).Select(x => (TypeReference)x.Value).ToArray();
             } else {
                 throw new InvalidOperationException("Unrecognised JsAttribute constructor");
             }
             if (isStatic != null) {
                 if (isStatic.Value == mRef.HasThis) {
                     return false;
                 }
             }
             if (aMethodName == null && aParameterTypes == null && mName == mRef.Name) {
                 return true;
             }
             if ((aMethodName ?? mName) != mRef.Name) {
                 return false;
             }
             if (aParameterTypes.Count() != mRef.Parameters.Count) {
                 return false;
             }
             if (aParameterTypes.Zip(mRef.Parameters, (x, y) => new { aType = x, mRefType = y.ParameterType }).Any(x => {
                 var aTypeResolved = x.aType.FullResolve(mRef);
                 var mRefTypeResolved = x.mRefType.FullResolve(mRef);
                 return !aTypeResolved.IsSame(mRefTypeResolved);
             })) {
                 return false;
             }
             var aReturnTypeResolved = aReturnType.FullResolve(mRef);
             var mRefReturnTypeResolved = mRef.ReturnType.FullResolve(mRef);
             if (!aReturnTypeResolved.IsSame(mRefReturnTypeResolved)) {
                 return false;
             }
             return true;
         });
     };
     var members = mappedTRef.EnumResolvedMethods(mRef);
     var member = members.FirstOrDefault(m => {
         var mr = m.Resolve();
         var attrs = mr.GetCustomAttributes<JsAttribute>();
         var match = isMatch(attrs, m.Name);
         return match;
     });
     return member;
 }
开发者ID:chrisdunelm,项目名称:DotNetWebToolkit,代码行数:59,代码来源:JsResolver.cs


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