Пример #1
0
        public ILFunc GetMethodFor(Type type)
        {
            if (_versions.TryGetValue(type, out var res))
            {
                return(res);
            }

            var genMethod = Method
                            .MakeGenericMethod(type);

            var method = genMethod
                         .ILWrapRefSupport();

            _versions.TryAdd(type, method);

            return(method);
        }
Пример #2
0
        public static bool TryHasAttribute(MemberInfo member, out T[] result)
        {
            if (!_memberInfoCache.TryGetValue(member, out result))
            {
                result = member.GetCustomAttributes <T>().ToArray();

                if (result.Length == 0)
                {
                    _memberInfoCache.TryAdd(member, result);
                    return(false);
                }

                _memberInfoCache.TryAdd(member, result);

                return(true);
            }

            return(result != default && result.Length != 0);
        }