///<inheritdoc cref="IQuestTree"/> public void Initialize() { lock (_locker) { //TODO: Retrieve top root and its children. Add them to flat list. //TODO: If there is no top root - create and save it. if (_isInitialized == false) { using (_dataLayer) { _dataLayer.Open(); Quest root = _dataLayer.Get(TopRootId); //If quest there is not root in data layer, there will be no children for it. if (root == null) { root = _questFactory.CreateQuest(); root.Id = TopRootId; _dataLayer.Insert(root); } else { //Try load children for root from data layer. InnerLoadChildren(root, _dataLayer); } _innerRoot = root; } _flatQuestTree.Add(_innerRoot); _isInitialized = true; } } }
///<inheritdoc cref="IQuestViewModelFactory"/> public IQuestViewModel CreateQuestViewModel() { return(new QuestViewModel { Model = _questFactory.CreateQuest() }); }