Convert SelectUrl definition to accept url overrides from config
This commit is contained in:
		
							parent
							
								
									db4fac4ce7
								
							
						
					
					
						commit
						77c390f254
					
				@ -1,19 +1,29 @@
 | 
				
			|||||||
using Connected.Services;
 | 
					using Connected.Services;
 | 
				
			||||||
 | 
					using Microsoft.Extensions.Configuration;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace Connected.ServiceModel.Client.Net;
 | 
					namespace Connected.ServiceModel.Client.Net;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
internal sealed class SelectUrl : ServiceFunction<ConnectedServerUrlArgs, string>
 | 
					internal sealed class SelectUrl : ServiceFunction<ConnectedServerUrlArgs, string>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	private const string Root = "https://localhost:61599";//"https://connected.tompit.com";
 | 
						private const string Root = "https://connected.tompit.com";
 | 
				
			||||||
	protected override async Task<string?> OnInvoke()
 | 
						private readonly string? _rootOverride = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public SelectUrl(IConfiguration configuration)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							_rootOverride = configuration?.GetValue<string?>("connectedServicesRootUrl", null);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private string RootUrl => string.IsNullOrWhiteSpace(_rootOverride) ? Root : _rootOverride;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						protected override async Task<string> OnInvoke()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		await Task.CompletedTask;
 | 
							await Task.CompletedTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return Arguments.Kind switch
 | 
							return Arguments.Kind switch
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			ConnectedUrlKind.Root => Root,
 | 
								ConnectedUrlKind.Root => RootUrl,
 | 
				
			||||||
			ConnectedUrlKind.FileSystem => $"{Root}/services/fileSystem",
 | 
								ConnectedUrlKind.FileSystem => $"{RootUrl}/services/fileSystem",
 | 
				
			||||||
			ConnectedUrlKind.TableStorage => $"{Root}/services/tables",
 | 
								ConnectedUrlKind.TableStorage => $"{RootUrl}/services/tables",
 | 
				
			||||||
			_ => throw new NotImplementedException(),
 | 
								_ => throw new NotImplementedException(),
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user