/// <summary> /// Trả về repository /// </summary> /// <param name="name">Tên đối tượng</param> /// <returns>Trả về repository</returns> /// Create by:dvthang:07.01.2018 public IRepository GetRepByName(string name) { IRepository repository = null; if (dicRepository != null && dicRepository.ContainsKey(name)) { repository = dicRepository[name]; repository.Init(this.transaction, this.m_DB); } else { repository = CreateRepByName(name); if (dicRepository == null) { dicRepository = new Dictionary <string, IRepository>(); } if (!dicRepository.ContainsKey(name)) { dicRepository.Add(name, repository); } } //Nếu đã hủy connection thì tạo lại if (this.connection == null) { this.connection = this.DB.CreateConnection(); this.connection.Open(); } return(repository); }
public void Visit(Config config, SyntaxNode n) { CodeSyntaxEntity codeSyntax = new CodeSyntaxEntity { Text = n.GetText().ToString(), TypeName = n.GetType().FullName }; _codeSyntaxRepository.Init(config); _codeSyntaxRepository.Create(codeSyntax); }
public void Visit(Config config, Type t) { BaseSyntaxEntity baseSyntax = new BaseSyntaxEntity { Name = t.Name, FullName = t.FullName }; _baseSyntaxRepository.Init(config); _baseSyntaxRepository.Create(baseSyntax); SyntaxCoollectionEntity syntax = new SyntaxCoollectionEntity { Name = t.Name, FullName = t.FullName }; _syntaxRepository.Init(config); _syntaxRepository.Create(syntax); }
public void Visit(Config config, Type t) { ConcreteSyntaxEntity concreteSyntax = new ConcreteSyntaxEntity { Name = t.Name, FullName = t.FullName, ParentFullName = t.BaseType.FullName }; _concreteSyntaxRepository.Init(config); _concreteSyntaxRepository.Create(concreteSyntax); SyntaxCoollectionEntity syntax = new SyntaxCoollectionEntity { Name = t.Name, FullName = t.FullName }; _syntaxRepository.Init(config); _syntaxRepository.Create(syntax); }
//TODO Заглушка для Dependency Inversion public void DI() { //Repo = new Data.DataRepository(); //Repo.Init(new string[] { @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=C:\USERS\СЕРГЕЙ\DOCUMENTS\ESPROJECT\ESPROJECT\BIN\DEBUG\BD4.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" }); Repo = new MockDataBase.MockRepository(); Repo.Init(null); Factors = new List<FactorSettings>(); AllocConsole(); loggingService = new NLogLoggingService(); //storage = DataConvertor.ConvertData(Repo.GetTeachers(), Repo.GetStudentsGroups(), Repo.GetClassRoomsTypes(), Repo.GetClassRooms(), Repo.GetStudentsClasses()); storage = CurrentBase.EStorage; vip = new Setting(storage, storage.Classes); loggingService.Info("Загружены данные"); }
public ICrudRepository <TEntity, TKey> Get <TEntity, TKey>(IEntityKeyAccossor keyAccossor) where TEntity : class, new() { var t = typeof(TEntity); if (_crudRepositories.ContainsKey(t)) { return(_crudRepositories[t] as ICrudRepository <TEntity, TKey>); } var name = t.Name.ToLower(); var attribute = t.GetCustomAttribute(typeof(ReadOptimizedAttribute)); var repo = attribute != null ? new DocumentCrudRepository <TEntity, TKey>(_repository.Init <List <TEntity> >(Path.Combine(_conn, name + ".json")).Result, keyAccossor) : new DocumentCollectionCrudRepository <TEntity, TKey>(_repository.InitCollection <TEntity>(Path.Combine(_conn, name)).Result, keyAccossor) as ICrudRepository <TEntity, TKey>; _crudRepositories.Add(t, repo); return(repo); }
public void Init() { _configuration = Configuration.GetConfiguration(); if (_repository.GetUser(_configuration.SystemUser.Login) == null) { _repository.Init(); _configuration.SystemUser.NewSecret(); _repository.Save(_configuration.SystemUser); var s1 = new Story(@"Анекдоты", @"Я думал, что к 30-ти годам я буду разъезжать на жёлтом ""Ламборджини"". А сейчас радуюсь жёлтым ценникам в ""Пятёрочке""."); _repository.Save(s1); var s2 = new Story(@"Анекдоты", @"Чтобы покорить женщину, одного желания мало. Лучше пообещать исполнить все её желания."); _repository.Save(s2); } }
private void OnResourceStart() { API.consoleOutput("Starting \"Rumble\"!"); repository = new JSONRepository(); repository.Init(); teleports = repository.Load <string, TeleportData>(); playerData = new Dictionary <string, PlayerData>(API.getMaxPlayers()); playerBlips = new Dictionary <Client, Blip>(); foreach (var player in API.getAllPlayers()) { OnPlayerConnected(player); } updateTimer = API.TickCount; }
public static EntityStorage CreateEntityStorage(IRepository repo, string[] connectionStrings) { EntityStorage storage; try { repo.Init(connectionStrings); List<DBTeacher> teachers = repo.GetTeachers().ToList(); List<DBStudentSubGroup> groups = repo.GetStudentsGroups().ToList(); List<DBClassRoomType> roomTypes = repo.GetClassRoomsTypes().ToList(); List<DBClassRoom> rooms = repo.GetClassRooms().ToList(); List<DBStudentsClass> classes = repo.GetStudentsClasses().ToList(); storage = MandarinCore.DataConvertor.ConvertData(teachers, groups, roomTypes, rooms, classes); } catch (Exception ex) { throw; } return storage; }
public VendingMachineService() { _inMemoryRepository = new InMemoryProductRepository(); _inMemoryRepository.Init(); PopulateVendingItem(); }
public bool Init() { lock (_ownLock) { try { bool initrepo1 = _archiveOptionRepository?.Init() ?? false; if (!initrepo1) { IsInitialized = false; State = State.Error; string message = Logger?.ErrorLog("Archive option repository could not be initialized.", CLASS_NAME); OnError(this, message); } else { _archiveOptionList = _archiveOptionRepository.GetAll(); IsInitialized = true; State = State.Ready; string message = Logger?.InfoLog($"Archive option repository initialized. Number of Options: {_archiveOptionList?.Count}", CLASS_NAME); OnInfo(this, message); } } catch (Exception ex) { IsInitialized = false; State = State.Error; string message = Logger?.ErrorLog($"Exception occured: {ex.Message}", CLASS_NAME); OnError(this, message); } try { bool initrepo2 = _shareRepository?.Init() ?? false; if (!initrepo2) { IsInitialized = false; State = State.Error; string message = Logger?.ErrorLog("Share repository could not be initialized.", CLASS_NAME); OnError(this, message); } else { _shareList = _shareRepository.GetAll(); IsInitialized &= true; State &= State.Idle; string message = Logger?.InfoLog($"Share repository initialized. Number of shares: {_shareList?.Count}", CLASS_NAME); OnInfo(this, message); } } catch (Exception ex) { IsInitialized = false; State = State.Error; string message = Logger?.ErrorLog($"Exception occured: {ex.Message}", CLASS_NAME); OnError(this, message); } return(IsInitialized); } }