Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public static MethodSearch FromSignature(MethodSignature signature)
        {
            var search = new MethodSearch();

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

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

                return(default(TBox));
            }
        }
Esempio n. 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]);
            }
        }
Esempio n. 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]);
            }
        }
Esempio n. 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]);
            }
        }
Esempio n. 8
0
 public TBox RegisterMethod(TBox methodBox, MethodSearch customSearch = null)
 {
     return(_methodInfoBoxCache.Add(customSearch ?? MethodSignature.FromMethodInfo(methodBox.MethodInfo), methodBox));
 }
Esempio n. 9
0
 public static MethodSearch FromMethodInfo(MethodInfo methodInfo)
 {
     return(MethodSearch.FromSignature(MethodSignature.FromMethodInfo(methodInfo)));
 }