示例#1
0
        public void GenerateResolver(GeneratedAssembly generatedAssembly)
        {
            if (_resolverType != null)
            {
                return;                        // got some kind of loop in here we need to short circuit
            }
            if (ErrorMessages.Any() || Dependencies.SelectMany(x => x.ErrorMessages).Any())
            {
                return;
            }

            var typeName = (ServiceType.FullNameInCode() + "_" + Name).Sanitize();


            var buildType = ServiceType.MustBeBuiltWithFunc() || ImplementationType.MustBeBuiltWithFunc()
                ? typeof(object)
                : ServiceType;

            _resolverType = generatedAssembly.AddType(typeName, ResolverBaseType.MakeGenericType(buildType));

            var method = _resolverType.MethodFor("Build");

            var frame = CreateBuildFrame();

            method.Frames.Add(frame);
        }
示例#2
0
        public void GenerateResolver(GeneratedAssembly generatedAssembly)
        {
            if (_resolverType != null)
            {
                return;                        // got some kind of loop in here we need to short circuit
            }
            if (ErrorMessages.Any() || Dependencies.SelectMany(x => x.ErrorMessages).Any())
            {
                return;
            }

            var typeName = (ServiceType.FullNameInCode() + "_" + Name).Sanitize();


            _resolverType = generatedAssembly.AddType(typeName, ResolverBaseType.MakeGenericType(ServiceType));

            foreach (var relatedAssembly in relatedAssemblies())
            {
                generatedAssembly.ReferenceAssembly(relatedAssembly);
            }

            var method = _resolverType.MethodFor("Build");

            var frame = CreateBuildFrame();

            method.Frames.Add(frame);
        }
示例#3
0
        internal (string, string) GenerateResolverClassCode(GeneratedAssembly generatedAssembly)
        {
            var typeName = GetResolverTypeName();


            var resolverType = generatedAssembly.AddType(typeName, ResolverBaseType.MakeGenericType(ServiceType));

            var method = resolverType.MethodFor("Build");

            var frame = CreateBuildFrame();

            method.Frames.Add(frame);

            return(typeName, generatedAssembly.GenerateCode());
        }
示例#4
0
        internal (string, string) GenerateResolverClassCode(GeneratedAssembly generatedAssembly)
        {
            var typeName = GetResolverTypeName();


            var buildType = ServiceType.MustBeBuiltWithFunc() || ImplementationType.MustBeBuiltWithFunc()
                ? typeof(object)
                : ServiceType;

            var resolverType = generatedAssembly.AddType(typeName, ResolverBaseType.MakeGenericType(buildType));

            var method = resolverType.MethodFor("Build");

            var frame = CreateBuildFrame();

            method.Frames.Add(frame);

            return(typeName, generatedAssembly.GenerateCode());
        }