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); }
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); }
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()); }
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()); }