private TBox _FindMethod(MethodSearch search)
        {
            var bindingFlags = search.Context.AccessModifier.ToBindingFlags().Add(search.Context.MethodType.ToBindingFlags());
            var methodInfo   = search.Context.OwnerType.FoundMatchingType.GetMethods(bindingFlags).FindBestMatchingMethodInfo(search);

            return(BuildMethod(MethodBoxBuilderContext.Build(methodInfo, Options)).MethodInfoBox);
        }
Example #2
0
        public static MethodSearch FromSignature(MethodSignature signature)
        {
            var search = new MethodSearch();

            search.Context = signature.ConvertTo <MethodSearchContext>();

            return(search);
        }
 public TBox FindMethod(MethodSearch search)
 {
     if (Options.EnableCache)
     {
         return(_methodInfoBoxCache.GetOrAdd(search, () => _FindMethod(search)));
     }
     else
     {
         return(_FindMethod(search));
     }
 }
Example #4
0
        internal TBox Get(MethodSearch search)
        {
            lock (_dictionaryLock) {
                var sig = search.ToString();
                if (_methodInfoBoxes.ContainsKey(sig))
                {
                    return(_methodInfoBoxes[sig]);
                }

                return(default(TBox));
            }
        }
Example #5
0
        internal TBox GetOrAdd(MethodSearch search, Func <TBox> box)
        {
            lock (_dictionaryLock) {
                var sig = search.ToString();
                if (_methodInfoBoxes.ContainsKey(sig))
                {
                    return(_methodInfoBoxes[sig]);
                }

                _methodInfoBoxes.Add(sig, box.Invoke());
                return(_methodInfoBoxes[sig]);
            }
        }
Example #6
0
        internal TBox Add(MethodSearch search, TBox box)
        {
            lock (_dictionaryLock) {
                var sig = search.ToString();
                if (_methodInfoBoxes.ContainsKey(sig))
                {
                    throw new Exception("A Mehod with same Key already exists!");
                }
                else
                {
                    _methodInfoBoxes.Add(sig, box);
                }


                return(_methodInfoBoxes[sig]);
            }
        }
Example #7
0
        internal TBox Add(MethodBoxBuilderResult <TBox> builderResult)
        {
            lock (_dictionaryLock) {
                var sig = builderResult.CustomSearch?.ToString() ?? MethodSearch.FromMethodInfo(builderResult.MethodInfoBox.MethodInfo).ToString();
                if (_methodInfoBoxes.ContainsKey(sig))
                {
                    throw new Exception("A Mehod with same Key already exists!");
                }
                else
                {
                    _methodInfoBoxes.Add(sig, builderResult.MethodInfoBox);
                }


                return(_methodInfoBoxes[sig]);
            }
        }
 public TBox RegisterMethod(TBox methodBox, MethodSearch customSearch = null)
 {
     return(_methodInfoBoxCache.Add(customSearch ?? MethodSignature.FromMethodInfo(methodBox.MethodInfo), methodBox));
 }
Example #9
0
 public static MethodSearch FromMethodInfo(MethodInfo methodInfo)
 {
     return(MethodSearch.FromSignature(MethodSignature.FromMethodInfo(methodInfo)));
 }