Guest User

Untitled

a guest
Feb 18th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public class GCCUPCCodeGenerator : IUPCCodeGenerator
  2. {
  3. IPersistence _persistence;
  4. string _gccPrefix;
  5.  
  6. public GCCUPCCodeGenerator(IPersistence persistence , string gccPrefix)
  7. {
  8. _persistence = persistence;
  9. }
  10.  
  11. services.AddScoped<IPersistence, Persistence>();
  12.  
  13. public class UnixConnection : IUnixDataStore
  14. {
  15. public UnixConnection(UnixConnectionOption connectionOptions)
  16. {
  17.  
  18. services.AddScoped<IUnixDataStore>(provider => ConfigureUnixConnectionObject());
  19. IUnixDataStore ConfigureUnixConnectionObject()
  20. {
  21. var connectionParam = new UnixConnectionOption
  22. {
  23. DBPort = Convert.ToInt32(Configuration["DBPort"]),
  24. SSHUserName = Configuration["SSHUserName"],
  25. SSHHostName = Configuration["SSHHostName"],
  26. SSHPassword = Configuration["SSHPassword"],
  27. SQLHostName = Configuration["SQLHostName"],
  28. SQLUserName = Configuration["SQLUserName"],
  29. SQLPassword = Configuration["SQLPassword"],
  30. SQLDatabaseName = Configuration["SQLDatabaseName"]
  31. };
  32. return new UnixConnection(connectionParam);
  33. }
  34.  
  35. services.AddScoped<IUPCCodeGenerator>(p =>
  36. {
  37. // `p` is a scoped instance of `IServiceProvider`, meaning you can pull services from it
  38. var persistence = p.GetRequiredService<IPersistence>();
  39. return new GCCUPCCodeGenerator(persistence, "prefix");
  40. });
Add Comment
Please, Sign In to add comment