コード例 #1
0
        internal MethodShuntKey(MethodShuntSource source, MethodInfo method) : base(method)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            this.Source = source;
        }
コード例 #2
0
        public static MethodShuntSource CreateSource(MethodInfo method)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            var source = new MethodShuntSource(method);

            MethodShunt.shuntDic.Add(source, new HashSet <MethodShuntKey>());

            return(source);
        }
コード例 #3
0
        public static MethodShuntKey Register(MethodShuntSource source, MethodInfo method)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            var key = new MethodShuntKey(source, method);

            MethodShunt.shuntDic[source].Add(key);

            return(key);
        }
コード例 #4
0
        public static MethodShuntResult DynamicInvokeShunt(this object target, MethodShuntSource source, params object[] parameters)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (MethodShunt.shuntDic.ContainsKey(source))
            {
                foreach (var key in MethodShunt.shuntDic[source])
                {
                    if (MethodShunt.DynamicInvokeShuntInternal(target, key, parameters, out object returnValue))
                    {
                        return(new MethodShuntResult(true, returnValue));
                    }
                }
            }

            return(MethodShuntResult.Unsuccess);
        }