Skip to content

Commit 915018a

Browse files
author
Victor.X.Qu (g-mis.cncd02.Newegg) 42377
committed
update Transient
update
1 parent d71d53a commit 915018a

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/Norns.Urd.HttpClient.NewtonsoftJson/NewtonsoftJosnServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class NewtonsoftJosnServiceCollectionExtensions
99
{
1010
public static IServiceCollection AddHttpClientNewtonsoftJosn(this IServiceCollection services)
1111
{
12-
services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHttpContentSerializer), typeof(NewtonsoftJosnContentSerializer)));
12+
services.TryAddEnumerable(ServiceDescriptor.Transient(typeof(IHttpContentSerializer), typeof(NewtonsoftJosnContentSerializer)));
1313
services.PostConfigure<JsonSerializerSettings>(i => { });
1414
return services;
1515
}

src/Norns.Urd.HttpClient/HttpClientServiceCollectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ public static IAspectConfiguration EnableHttpClient(this IAspectConfiguration co
1616
services.TryAddSingleton<IHttpClientFactoryHandler, HttpClientFactoryHandler>();
1717
services.TryAddSingleton<IHttpRequestDynamicPathFactory, ConfigurationDynamicPathFactory>();
1818
services.TryAddSingleton<IQueryStringBuilder, QueryStringBuilder>();
19-
services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHttpContentSerializer), typeof(SystemTextJsonContentSerializer)));
20-
services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHttpContentSerializer), typeof(OctetStreamContentSerializer)));
21-
services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHttpClientHandler), typeof(EnsureSuccessStatusCodeHandler)));
19+
services.TryAddEnumerable(ServiceDescriptor.Transient(typeof(IHttpContentSerializer), typeof(SystemTextJsonContentSerializer)));
20+
services.TryAddEnumerable(ServiceDescriptor.Transient(typeof(IHttpContentSerializer), typeof(OctetStreamContentSerializer)));
21+
services.TryAddEnumerable(ServiceDescriptor.Transient(typeof(IHttpClientHandler), typeof(EnsureSuccessStatusCodeHandler)));
2222
services.PostConfigure<JsonSerializerOptions>(i =>
2323
{
2424
i.PropertyNameCaseInsensitive = true;
2525
i.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
2626
});
27-
services.TryAddEnumerable(ServiceDescriptor.Singleton(typeof(IHttpContentSerializer), typeof(XmlContentSerializer)));
27+
services.TryAddEnumerable(ServiceDescriptor.Transient(typeof(IHttpContentSerializer), typeof(XmlContentSerializer)));
2828
services.PostConfigure<XmlContentSerializerOptions>(i => { });
2929
});
3030
return configuration;

test/Examples.WebApi/TestClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ public interface ITestClient
2222
[OctetStreamContentType]
2323
Task UpoladAsync([Body]Stream f);
2424
}
25+
26+
public class LoginUser
27+
{
28+
public string UserName { get; set; }
29+
public string Password { get; set; }
30+
public bool RememberMe { get; set; }
31+
}
2532
}

0 commit comments

Comments
 (0)