public Form1() { FactorySupport factorySupport = new FactorySupport(); Log.Logger = new LoggerConfiguration().WriteTo.File(@"C:\Log\Log.txt", rollingInterval: RollingInterval.Hour).CreateLogger(); Directory.CreateDirectory(@"C:\db"); LiteRepository repo = new LiteRepository(ApplicationConfig.DbConnectionString); frameWork = factorySupport.Create(isMySQL, repo); InitializeComponent(); }
public Loginform() { eventMediator = new EventMediator(); // feliratkozás az ErrorMessage Event-re // hibaüzenet esetén az OnErrorMessage metódus megjeleníti a hibaüzenetet eventMediator.ErrorMessage += OnErrorMessage; FactorySupport factorySupport = new FactorySupport(); Directory.CreateDirectory(@"C:\Log"); Log.Logger = new LoggerConfiguration().WriteTo.File(@"C:\Log\Log.txt", rollingInterval: RollingInterval.Hour).CreateLogger(); Directory.CreateDirectory(@"C:\db"); LiteRepository repo = new LiteRepository(ApplicationConfig.DbConnectionString); frameWork = factorySupport.Create(isMySQL, repo, eventMediator); // példa: lekéri a GetService() -vel a UIFactory szervízt // utána kirajzol egy button-t a felhasználói felületen. uiFactory = (IUIFactory)(frameWork.GetService(typeof(IUIFactory))); if (uiFactory == null) { throw new Exception("Hibás UIFactory!"); } // Betölti az egész adatbázist a memóriába //MessageBox.Show("Beolvasom az adatbázist a memóriába"); frameWork.LoadDatabase(); // példa: lekéri a GetService() -vel az IErrorservice szervízt // utána megjeleníti a hibaüzenetet IErrorService errorService = (IErrorService)(frameWork.GetService(typeof(IErrorService))); if (errorService == null) { throw new Exception("Hibás ErrorService!"); } /*IError error = new Error(ErrorType.InputError, "Példa a beviteli hibára"); * errorService.Write(error); * * // hibeüzenet 2. példa * IError errorExample2 = new Error(ErrorType.DatabaseError, "Példa: Adatbázis üzenet a datalayertől"); * errorService.Write(errorExample2);*/ userService = (IUserService)(frameWork.GetService(typeof(IUserService))); InitializeComponent(); }