private static EnvironmentSection GetEnvironmentSection() { if (_environmentSection == null) { _environmentSection = (EnvironmentSection)ConfigurationManager.GetSection($"environmentSection"); } return(_environmentSection); }
public static EnvironmentElement GetEnvironmentElement(string name) { EnsureArg.IsNotNullOrWhiteSpace(name, nameof(name)); EnvironmentSection environmentSection = GetEnvironmentSection(); if (!environmentSection.Items.Exists(name)) { return(null); } EnvironmentElement environment = environmentSection.Items[name] as EnvironmentElement; return(environment); }
public string GetUrl(EnvironmentSection section, EnvironmentService service) { var serviceName = $"{section}:{service}"; var appSettingsName = "appsettings"; if (_hostingEnvironment.IsDevelopment()) { appSettingsName = $"{appSettingsName}.Development"; } var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile($"{appSettingsName}.json"); var configuration = builder.Build(); var url = configuration[serviceName]; return(_hostingEnvironment.IsProduction() ? Environment.GetEnvironmentVariable(url) : url); }
public static FhirToolArguments Create(string[] args) { EnsureArg.IsNotNull(args, nameof(args)); FhirToolArguments arguments = new FhirToolArguments(); for (int i = 0; i < args.Length; i++) { string arg = args[i]; switch (arg) { case GENERATE_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.Generate; break; case UPLOAD_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.Upload; break; case UPLOAD_DEFINITIONS_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.UploadDefinitions; break; case BUNDLE_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.Bundle; break; case SPLIT_BUNDLE_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.SplitBundle; break; case TRANSFER_DATA_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.TransferData; break; case VERIFY_VALIDATION_OP: if (arguments.Operation != OperationEnum.None) { throw new MultipleOperationException(arguments.Operation); } arguments.Operation = OperationEnum.VerifyValidation; break; case QUESTIONNAIRE_ARG: case QUESTIONNAIRE_SHORT_ARG: arguments.QuestionnairePath = args[i + 1]; break; case VALUESET_ARG: case VALUESET_SHORT_ARG: arguments.ValueSetPath = args[i + 1]; break; case FHIRBASEURL_ARG: case FHIRBASEURL_SHORT_ARG: arguments.FhirBaseUrl = args[i + 1]; break; case VERSION_ARG: case VERSION_SHORT_ARG: arguments.Version = args[i + 1]; break; case RESOLVEURL_ARG: case RESOLVEURL_SHORT_ARG: arguments.ResolveUrl = true; break; case VERBOSE_ARG: case VERBOSE_SHORT_ARG: arguments.Verbose = true; break; case MIMETYPE_ARG: case MIMETYPE_SHORT_ARG: string mimeType = args[i + 1].ToLowerInvariant(); if (!SUPPORTED_MIMETYPES.Contains(mimeType)) { throw new NotSupportedMimeTypeException(mimeType); } arguments.MimeType = mimeType; break; case SOURCE_ARG: case SOURCE_SHORT_ARG: arguments.SourcePath = args[i + 1]; break; case OUT_ARG: case OUT_SHORT_ARG: arguments.OutPath = args[i + 1]; break; case CREDENTIALS_ARG: case CREDENTIALS_SHORT_ARG: arguments.Credentials = args[i + 1]; break; case ENVIRONMENT_ARG: case ENVIRONMENT_SHORT_ARG: arguments.Environment = args[i + 1]; EnvironmentSection environmentSection = (EnvironmentSection)ConfigurationManager.GetSection($"environmentSection"); EnvironmentElement environment = (EnvironmentElement)environmentSection.Items[arguments.Environment]; arguments.FhirBaseUrl = environment.FhirBaseUrl; arguments.ProxyBaseUrl = environment.ProxyBaseUrl; break; case ENVIRONMENT_SOURCE_ARG: case ENVIRONMENT_SOURCE_SHORT_ARG: arguments.SourceEnvironment = args[i + 1]; break; case ENVIRONMENT_DESTINATION_ARG: case ENVIRONMENT_DESTINATION_SHORT_ARG: arguments.DestinationEnvironment = args[i + 1]; break; case RESOURCETYPE_ARG: case RESOURCETYPE_SHORT_ARG: arguments.ResourceType = EnumUtility.ParseLiteral <ResourceType>(args[i + 1]); break; case SEARCHCOUNT_ARG: case SEARCHCOUNT_SHORT_ARG: int searchCount; if (!int.TryParse(args[i + 1], out searchCount)) { throw new RequiredArgumentException($"{SEARCHCOUNT_ARG}|{SEARCHCOUNT_SHORT_ARG}"); } arguments.SearchCount = searchCount; break; case SKIP_VALIDATION_ARG: case SKIP_VALIDATION_SHORT_ARG: arguments.SkipValidation = true; break; default: break; } } return(arguments); }