Example #1
0
        /*实现本API请遵循以下规范:
         * 如果ExactlySame为假,那么签名兼容指的是:
         * 本对象的返回值和参数可以用在Other身上,而不是相反*/
        #endregion
        #region 辅助方法
        /// <summary>
        /// 用来比较类型的辅助方法,支持协变
        /// </summary>
        /// <param name="Other">要比较的另一个方法签名</param>
        /// <param name="ExactlySame">如果这个值为<see langword="true"/>,则要求两个签名完全相同,
        /// 如果为<see langword="false"/>,则可以支持协变与逆变</param>
        /// <returns></returns>
        private protected bool Aided(MethodBaseSignature Other, bool ExactlySame)
        {
            var otherPar = Other.Parameters;

            if (otherPar.Count != Parameters.Count)
            {
                return(false);
            }
            return(Parameters.Zip(otherPar, false).All(x =>
            {
                var(s, o) = x;
                return ExactlySame ? s == o : o?.IsAssignableFrom(s) ?? false;
            }));
        }
Example #2
0
 public override bool IsSame(MethodBaseSignature Other, bool ExactlySame = true)
 => Other is ConstructSignature other && Aided(other, ExactlySame);
Example #3
0
 /// <summary>
 /// 判断这个签名和另一个方法签名是否兼容
 /// </summary>
 /// <param name="Other">要比较的另一个签名</param>
 /// <param name="ExactlySame">如果这个值为<see langword="true"/>,则要求两个签名完全相同,
 /// 如果为<see langword="false"/>,则可以支持协变与逆变</param>
 /// <returns></returns>
 public abstract bool IsSame(MethodBaseSignature Other, bool ExactlySame = true);