public Action ParseArguments(string[] arguments) { if (arguments.Length == 0) { throw new EmptyArgumentsException($"{UserMessages.EmptyArguments} {UserMessages.SpecifyArguments}"); } if (arguments.Length < RequiredArgumentsCount) { throw new InvalidArgumentException( $"{UserMessages.SomeArgumentsAreMissing} {UserMessages.SpecifyArguments}"); } var command = arguments[CommandIndex]; var inputFilePath = arguments[InputFileIndex]; var outputFilePath = arguments[OutputFileIndex]; ValidatePath(inputFilePath, "Input"); ValidatePath(outputFilePath, "Output"); IFileService fileService = FileServiceFactory.GetFileService(); var delegateToCall = GetDelegateToCall(command, fileService); return(() => delegateToCall(inputFilePath, outputFilePath)); }
public DataServices(IDataBaseService dataBaseService) { LoginService = new LoginService(dataBaseService); UserService = new UserService(dataBaseService); DoctorService = new DoctorService(dataBaseService); ConsultationService = new ConsultationService(dataBaseService); SecureFileService = new SecureFileService(dataBaseService, FileServiceFactory.GetFileSystem()); NonSecureFileService = new NonSecureFileService(dataBaseService, FileServiceFactory.GetFileSystem()); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <UserContext>(options => options.UseNpgsql("Host=localhost;Database=Nakigoe;Username=postgres;Password=1234")); var key = Encoding.ASCII.GetBytes("//TODO: Change me"); services.AddAuthentication(config => { config.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; config.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); services.AddScoped <IUSerService, UserService>(); services.AddSingleton <IFileService>(FileServiceFactory.Create(Configuration["ProfilePicDir"])); services .AddControllers() .AddJsonOptions(options => // Output data as is rather than converting it to camel case options.JsonSerializerOptions.PropertyNamingPolicy = null); services.AddCors(options => options.AddPolicy("Disable", builder => { builder .AllowAnyHeader() .AllowAnyMethod() .AllowAnyOrigin(); })); }