예제 #1
0
        public override bool IsAvailable(IUserDataHolder cache)
        {
            const string handlerStr        = "Handler";
            var          classIsHandler    = classDeclaration?.NameIdentifier?.Name.Contains(handlerStr) ?? false;
            var          baseTypeIsHandler = classDeclaration?.GetAllSuperTypes().Any(x => x.GetClrName().ShortName.Contains(handlerStr)) ?? false;

            invocationsExpressions = methodDeclaration?.Body?.GetAllDescendants().OfType <IInvocationExpression>().ToArray() ?? Array.Empty <IInvocationExpression>();
            var getTablePresented = invocationsExpressions.Any(x => (x.InvokedExpression as IReferenceExpression)?.NameIdentifier.Name == "GetTable");

            return(methodDeclaration != null && (classIsHandler || baseTypeIsHandler || getTablePresented));
        }
예제 #2
0
        public override bool IsAvailable(IUserDataHolder cache)
        {
            ctor = error?.Reference?.Resolve().DeclaredElement as IConstructor;
            if (ctor == null)
            {
                return(false);
            }

            // ReSharper disable once PossibleNullReferenceException
            var ctorTreeNode = error?.Reference.GetTreeNode();

            classDeclaration = ctorTreeNode.FindParent <IClassDeclaration>();
            if (classDeclaration == null)
            {
                return(false);
            }

            superTypes = classDeclaration.GetAllSuperTypes().ToArray();
            return(superTypes.Any(x => x.GetClassType()?.Methods.Any(y => y.ShortName == "NewMock") ?? false));
        }