protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { includeSubnamespaces = false; var argument = match.GetMatchedElement("subnamespace") as ICSharpArgument; if (argument != null) { if (argument.Value.ConstantValue != null && argument.Value.ConstantValue.IsBoolean()) { includeSubnamespaces = Convert.ToBoolean(argument.Value.ConstantValue.Value); } } var declaredType = match.GetMatchedType("type") as IDeclaredType; if (declaredType != null) { ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement != null) { return typeElement.GetContainingNamespace(); } } return null; }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var argument = match.GetMatchedElement("argument") as ICSharpArgument; if (argument != null) { INamespace @namespace = PsiExtensions.GetNamespaceDeclaration(argument.Value); if (@namespace != null) { yield return new InNamespaceRegistration(registrationRootElement, @namespace, true); } } }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var declaredType = match.GetMatchedType("type") as IDeclaredType; if (declaredType != null) { ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement != null) { yield return new InNamespaceRegistration(registrationRootElement, typeElement.GetContainingNamespace(), true); } } }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var matchedType = match.GetMatchedType("type") as IDeclaredType; if (matchedType != null) { ITypeElement typeElement = matchedType.GetTypeElement(); if (typeElement != null) { yield return new ExceptRegistration(registrationRootElement, typeElement); } } }
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { includeSubnamespaces = true; var argument = (ICSharpArgument)match.GetMatchedElement("argument"); if (argument != null) { return PsiExtensions.GetNamespaceDeclaration(argument.Value); } return null; }
protected override IEnumerable<BasedOnRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var matchedType = match.GetMatchedType("service") as IDeclaredType; if (matchedType != null) { ITypeElement typeElement = matchedType.GetTypeElement(); if (typeElement != null) { // todo possible bug here. Investigate wheather As and AssignableTo differ somehow in the result. yield return new ElementBasedOnRegistration(registrationRootElement, typeElement); } } }
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { includeSubnamespaces = true; var declaredType = match.GetMatchedType("type") as IDeclaredType; if (declaredType != null) { ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement != null) { return typeElement.GetContainingNamespace(); } } return null; }
private static IEnumerable<ITypeElement> GetRegisteredTypes(IStructuralMatchResult match, ICSharpExpression expression) { // match typeof() expressions var typeOfExpression = expression as ITypeofExpression; if (typeOfExpression != null) { var typeElement = (IDeclaredType)typeOfExpression.ArgumentType; yield return typeElement.GetTypeElement(); } // match new[] or new Type[] expressions var arrayExpression = expression as IArrayCreationExpression; if (arrayExpression != null) { foreach (var initializer in arrayExpression.ArrayInitializer.ElementInitializers.OfType<IExpressionInitializer>()) { foreach (ITypeElement type in GetRegisteredTypes(match, initializer.Value)) { yield return type; } } } // match new List<Type> expressions var objectCreationExpression = expression as IObjectCreationExpression; if (objectCreationExpression != null) { foreach (var initializer in objectCreationExpression.Initializer.InitializerElements.OfType<ICollectionElementInitializer>()) { // todo fixme find out if THERE CAN BE ONLY ONE!!!1 if (initializer.Arguments.Count != 1) { continue; } foreach (ITypeElement type in GetRegisteredTypes(match, initializer.Arguments[0].Value)) { yield return type; } } } }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var argument = match.GetMatchedElement("argument") as ICSharpArgument; if (argument != null) { var typeOfExpression = argument.Value as ITypeofExpression; if (typeOfExpression != null) { var argumentType = typeOfExpression.ArgumentType as IDeclaredType; if (argumentType != null) { var typeElement = argumentType.GetTypeElement(); if (typeElement == null) { yield break; } yield return new ClosingTypesRegistration(registrationRootElement, typeElement); } } } }
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { var arguments = match.GetMatchedElementList("arguments").Cast<ICSharpArgument>().ToArray(); INamespace namespaceElement = null; if (arguments.Length > 0) { namespaceElement = GetNamespaceDeclaration(arguments[0].Value); } includeSubnamespaces = false; if (arguments.Length == 2) { ICSharpArgument boolArgument = arguments[1]; if (boolArgument.Value.ConstantValue != null && boolArgument.Value.ConstantValue.IsBoolean()) { includeSubnamespaces = Convert.ToBoolean(boolArgument.Value.ConstantValue.Value); } } return namespaceElement; }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var argument = match.GetMatchedElement("argument") as ICSharpArgument; if (argument == null) { yield break; } var typeofExpression = argument.Value as ITypeofExpression; if (typeofExpression != null) { var declaredType = typeofExpression.ArgumentType as IDeclaredType; if (declaredType != null) { ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement != null) { // todo possible bug: same as in the generic variant. Currently works the same as As<T>. yield return new ServiceRegistration(registrationRootElement, typeElement); } } } }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var arguments = match.GetMatchedElementList("arguments").Cast<ICSharpArgument>(); foreach (var argument in arguments) { // match typeof() expressions var typeOfExpression = argument.Value as ITypeofExpression; if (typeOfExpression != null) { var argumentType = typeOfExpression.ArgumentType as IDeclaredType; if (argumentType != null) { var typeElement = argumentType.GetTypeElement(); if (typeElement == null) // can happen if the typeof() expression is empty { yield break; } yield return new ServiceRegistration(registrationRootElement, typeElement); } } } }
protected abstract IModule GetTargetModule(IStructuralMatchResult match);
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { var arguments = match.GetMatchedElementList("arguments").Cast <ICSharpArgument>().ToArray(); return(NamespaceExtractor.GetNamespace(arguments, out includeSubnamespaces)); }
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { return(NamespaceExtractor.GetNamespace(match, out includeSubnamespaces)); }
protected override IModule GetTargetModule(IStructuralMatchResult match) { var argument = (ICSharpArgument)match.GetMatchedElement("assemblyName"); return(ModuleExtractor.GetTargetModule(argument.Value)); }
protected abstract IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match);
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { var arguments = match.GetMatchedElementList("arguments").Cast<ICSharpArgument>().ToArray(); return NamespaceExtractor.GetNamespace(arguments, out includeSubnamespaces); }
protected override IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { yield return new ImplementedInterfacesRegistration(registrationRootElement); }
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var declaredType = match.GetMatchedType("type") as IDeclaredType; if (declaredType != null) { ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement != null) { yield return(new InNamespaceRegistration(registrationRootElement, typeElement.GetContainingNamespace(), true)); } } }
protected override IModule GetTargetModule(IStructuralMatchResult match) { return(ModuleExtractor.GetTargetModule(match.GetMatchedType("type"))); }
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var matchedType = match.GetMatchedType("service") as IDeclaredType; if (matchedType != null) { ITypeElement typeElement = matchedType.GetTypeElement(); if (typeElement != null) { yield return(new ServiceRegistration(registrationRootElement, typeElement)); } } }
protected abstract INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces);
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var argument = match.GetMatchedElement("argument") as ICSharpArgument; if (argument != null) { var typeOfExpression = argument.Value as ITypeofExpression; if (typeOfExpression != null) { var argumentType = typeOfExpression.ArgumentType as IDeclaredType; if (argumentType != null) { var typeElement = argumentType.GetTypeElement(); if (typeElement == null) { yield break; } yield return(new ClosingTypesRegistration(registrationRootElement, typeElement)); } } } }
protected override IEnumerable <BasedOnRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { yield return(new ImplementedInterfacesRegistration(registrationRootElement)); }
protected abstract IEnumerable<FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match);
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var argument = match.GetMatchedElement("argument") as ICSharpArgument; if (argument != null) { INamespace @namespace = ReSharper.Domain.Utils.PsiExtensions.GetNamespaceDeclaration(argument.Value); if (@namespace != null) { yield return(new InNamespaceRegistration(registrationRootElement, @namespace, true)); } } }
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var arguments = match.GetMatchedElementList("arguments").Cast <ICSharpArgument>(); foreach (var argument in arguments) { // match typeof() expressions var typeOfExpression = argument.Value as ITypeofExpression; if (typeOfExpression != null) { var argumentType = typeOfExpression.ArgumentType as IDeclaredType; if (argumentType != null) { var typeElement = argumentType.GetTypeElement(); if (typeElement == null) // can happen if the typeof() expression is empty { yield break; } yield return(new ServiceRegistration(registrationRootElement, typeElement)); } } } }
protected override INamespace GetNamespaceElement(IStructuralMatchResult match, out bool includeSubnamespaces) { return NamespaceExtractor.GetNamespace(match, out includeSubnamespaces); }
protected override IModule GetTargetModule(IStructuralMatchResult match) { return ModuleExtractor.GetTargetModule(match.GetMatchedType("type")); }
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var argument = match.GetMatchedElement("argument") as ICSharpArgument; if (argument == null) { yield break; } var typeofExpression = argument.Value as ITypeofExpression; if (typeofExpression != null) { var declaredType = typeofExpression.ArgumentType as IDeclaredType; if (declaredType != null) { ITypeElement typeElement = declaredType.GetTypeElement(); if (typeElement != null) { // todo possible bug: same as in the generic variant. Currently works the same as As<T>. yield return(new ServiceRegistration(registrationRootElement, typeElement)); } } } }
protected override IEnumerable <FilteredRegistrationBase> DoCreateRegistrations(ITreeNode registrationRootElement, IStructuralMatchResult match) { var matchedType = match.GetMatchedType("service") as IDeclaredType; if (matchedType != null) { ITypeElement typeElement = matchedType.GetTypeElement(); if (typeElement != null) { // todo possible bug here. Investigate wheather As and AssignableTo differ somehow in the result. yield return(new ServiceRegistration(registrationRootElement, typeElement)); } } }
protected override IModule GetTargetModule(IStructuralMatchResult match) { var argument = (ICSharpArgument)match.GetMatchedElement("argument"); return ModuleExtractor.GetTargetModule(argument.Value); }
protected override IModule GetTargetModule(IStructuralMatchResult match) { return match.MatchedElement.GetPsiModule().ContainingProjectModule; }
protected override IModule GetTargetModule(IStructuralMatchResult match) { return(match.MatchedElement.GetPsiModule().ContainingProjectModule); }