예제 #1
0
파일: Rules.cs 프로젝트: WrongDog/Sequence
        public static bool IsValidCall(object insOperand, ICallRules callRules)
        {
          string operandMethodName = string.Empty;
          string declaringTypeName = string.Empty;

          KeyValuePair<string, string> operandMethodAndDeclaringType = callRules.DetermineOperandAndDeclaringType(insOperand);

          operandMethodName = operandMethodAndDeclaringType.Key;
          declaringTypeName = operandMethodAndDeclaringType.Value;

          // must not be true
          if (operandMethodName.Length == 0 || declaringTypeName.Length == 0)
          {
            return false;
          }

          // check if the method we are calling is valid
          if (!IsValidMethod(operandMethodName))
          {
            return false;
          }

          // now check in ignored classes
          var query = from ignoredType in Settings.IgnoredTypeList()
                      where declaringTypeName.StartsWith(ignoredType, StringComparison.OrdinalIgnoreCase)
                      select ignoredType;

          return query.Count() == 0;
        }
예제 #2
0
파일: Rules.cs 프로젝트: WrongDog/Sequence
        /// <summary>
        /// Check if the callee method and declaring type is valid
        /// </summary>
        /// <param name="insOperand"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static bool IsValidCall(object insOperand, string typeName, ICallRules callRules)
        {
            if (!IsValidType(typeName))
            {
                return false;
            }

            return IsValidCall(insOperand, callRules);
        }