Beispiel #1
0
        internal override DependencyRegistration GetRegistration(
            IMethodSymbol method,
            SeparatedSyntaxList <ArgumentSyntax> arguments,
            SemanticModel semanticModel
            )
        {
            ITypeSymbol concreteType = GetConstructedTypeOfIFactory(
                semanticModel,
                method.TypeArguments[0],
                method.TypeArguments[1]
                );

            return(DependencyRegistration.Factory(
                       ObjectScope.AlwaysCreateNewInstance,
                       method.TypeArguments[0],
                       method.TypeArguments[1],
                       concreteType
                       ));
        }
        private DependencyRegistration GetFactoryRegistration(IMethodSymbol method, SeparatedSyntaxList <ArgumentSyntax> arguments, SemanticModel semanticModel)
        {
            ObjectScope scope;

            if (!TryGetObjectScope(arguments[0], semanticModel, out scope))
            {
                return(null);
            }

            ITypeSymbol concreteType = GetConstructedTypeOfIFactory(
                semanticModel,
                method.TypeArguments[0],
                method.TypeArguments[1]
                );

            return(DependencyRegistration.Factory(
                       scope,
                       dependencyType: method.TypeArguments[0],
                       factoryType: method.TypeArguments[1],
                       concreteType: concreteType
                       ));
        }
        internal override DependencyRegistration GetRegistration(IMethodSymbol method, SeparatedSyntaxList <ArgumentSyntax> arguments, SemanticModel semanticModel)
        {
            if (arguments.Count != 1)
            {
                return(null);
            }

            ObjectScope scope;

            if (!TryGetObjectScope(arguments[0], semanticModel, out scope))
            {
                return(null);
            }

            if (method.Name.Contains("Factory"))
            {
                ITypeSymbol concreteType = GetConstructedTypeOfIFactory(
                    semanticModel,
                    method.TypeArguments[0],
                    method.TypeArguments[1]
                    );

                return(DependencyRegistration.Factory(
                           scope,
                           method.TypeArguments[1],
                           method.TypeArguments[2],
                           concreteType
                           ));
            }
            else
            {
                return(DependencyRegistration.NonFactory(
                           scope,
                           method.TypeArguments[1],
                           method.TypeArguments[2]
                           ));
            }
        }