當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。