public IList <LibraryCategory> GetCategoryBreadCrumb(LibraryCategory category, IList <LibraryCategory> allCategories = null, bool showHidden = false) { if (category == null) { throw new ArgumentNullException(nameof(category)); } var result = new List <LibraryCategory>(); //used to prevent circular references var alreadyProcessedCategoryIds = new List <int>(); while (category != null && //not null !category.Deleted && //not deleted (showHidden || category.Published) && //published (showHidden || _aclService.Authorize(category)) && //ACL (showHidden || _storeMappingService.Authorize(category)) && //Store mapping !alreadyProcessedCategoryIds.Contains(category.Id)) //prevent circular references { result.Add(category); alreadyProcessedCategoryIds.Add(category.Id); category = allCategories != null?allCategories.FirstOrDefault(c => c.Id == category.ParentCategoryId) : GetCategoryById(category.ParentCategoryId); } result.Reverse(); return(result); }
protected virtual void UpdateLocales(LibraryCategory category, LibraryCategoryModel model) { foreach (var localized in model.Locales) { _localizedEntityService.SaveLocalizedValue(category, x => x.Name, localized.Name, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.Description, localized.Description, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); _localizedEntityService.SaveLocalizedValue(category, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); //search engine name var seName = _urlRecordService.ValidateSeName(category, localized.SeName, localized.Name, false); _urlRecordService.SaveSlug(category, seName, localized.LanguageId); } }
public void DeleteCategory(LibraryCategory category) { if (category == null) { throw new ArgumentNullException(nameof(category)); } if (category is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } category.Deleted = true; UpdateCategory(category); //event notification _eventPublisher.EntityDeleted(category); //reset a "Parent category" property of all child subcategories var subcategories = GetAllCategoriesByParentCategoryId(category.Id, true); foreach (var subcategory in subcategories) { subcategory.ParentCategoryId = 0; UpdateCategory(subcategory); } }
protected virtual void SaveCategoryAcl(LibraryCategory category, LibraryCategoryModel model) { category.SubjectToAcl = model.SelectedCustomerRoleIds.Any(); var existingAclRecords = _aclService.GetAclRecords(category); var allCustomerRoles = _customerService.GetAllCustomerRoles(true); foreach (var customerRole in allCustomerRoles) { if (model.SelectedCustomerRoleIds.Contains(customerRole.Id)) { //new role if (existingAclRecords.Count(acl => acl.CustomerRoleId == customerRole.Id) == 0) { _aclService.InsertAclRecord(category, customerRole.Id); } } else { //remove role var aclRecordToDelete = existingAclRecords.FirstOrDefault(acl => acl.CustomerRoleId == customerRole.Id); if (aclRecordToDelete != null) { _aclService.DeleteAclRecord(aclRecordToDelete); } } } }
public Library[] GetLibrariesOfType(LibraryCategory LibraryCategory, MFProject proj, MFSolution solution) { List <Library> ret = new List <Library>(); foreach (Inventory inv in m_invs) { foreach (Library lib in inv.Libraries) { if (lib.LibraryCategory != null) { if (string.IsNullOrEmpty(lib.LibraryCategory.Guid)) { continue; } if (0 == string.Compare(lib.LibraryCategory.Guid, LibraryCategory.Guid, true)) { ret.Add(lib); } } } } return(ret.ToArray()); }
protected virtual void SaveStoreMappings(LibraryCategory category, LibraryCategoryModel model) { category.LimitedToStores = model.SelectedStoreIds.Any(); var existingStoreMappings = _storeMappingService.GetStoreMappings(category); var allStores = _storeService.GetAllStores(); foreach (var store in allStores) { if (model.SelectedStoreIds.Contains(store.Id)) { //new store if (existingStoreMappings.Count(sm => sm.StoreId == store.Id) == 0) { _storeMappingService.InsertStoreMapping(category, store.Id); } } else { //remove store var storeMappingToDelete = existingStoreMappings.FirstOrDefault(sm => sm.StoreId == store.Id); if (storeMappingToDelete != null) { _storeMappingService.DeleteStoreMapping(storeMappingToDelete); } } } }
void OnCategoryPressed(LibraryCategory cat) { typeInfoCanvas.SetCanvas(false); //Delete bottom lines when all scroller are implemented: var current = categoryScrollerCanvases.FirstOrDefault(i => i.category == _activeCategory); if (current != null) { current.SetCanvas(false); } foreach (var item in categoryScrollerCanvases) { if (item.category == cat && !item.IsCanvasActive()) { current = categoryScrollerCanvases.FirstOrDefault(i => i.category == _activeCategory); if (current != null) { current.SetCanvas(false); } item.SetCanvas(true); } } exitButtonText.text = "exit"; _activeCategory = cat; categoryPanel.selectTypeText.text = SELECT_ONE_TYPE_TEXT; }
public LibraryCategoryForCaching(LibraryCategory c) { Id = c.Id; Name = c.Name; Description = c.Description; CategoryTemplateId = c.CategoryTemplateId; MetaKeywords = c.MetaKeywords; MetaDescription = c.MetaDescription; MetaTitle = c.MetaTitle; ParentCategoryId = c.ParentCategoryId; PictureId = c.PictureId; PageSize = c.PageSize; AllowCustomersToSelectPageSize = c.AllowCustomersToSelectPageSize; PageSizeOptions = c.PageSizeOptions; PriceRanges = c.PriceRanges; ShowOnHomePage = c.ShowOnHomePage; IncludeInTopMenu = c.IncludeInTopMenu; SubjectToAcl = c.SubjectToAcl; LimitedToStores = c.LimitedToStores; Published = c.Published; Deleted = c.Deleted; DisplayOrder = c.DisplayOrder; CreatedOnUtc = c.CreatedOnUtc; UpdatedOnUtc = c.UpdatedOnUtc; }
public IEnumerable <object> SelectItem(LibraryCategory category, string itemName, string authorName, DateTime?datePrint) { IEnumerable <object> filteredList = ItemCollection.itemList. FindAll(item => IsMatchItem(category, itemName, authorName, datePrint, item)); return(filteredList); }
public override void Init(string type, LibraryCategory cat, Action <LibraryCategory, string> OnPressedCallback, GameManager gm) { _type = type; typeText.text = _type; _fromCategory = cat; _btn = GetComponentInChildren <Button>(); _btn.onClick.AddListener(() => OnPressedCallback(_fromCategory, _type)); }
protected virtual void UpdatePictureSeoNames(LibraryCategory category) { var picture = _pictureService.GetPictureById(category.PictureId); if (picture != null) { _pictureService.SetSeoFilename(picture.Id, _pictureService.GetPictureSeName(category.Name)); } }
public void OnCategoryTypeButtonPressed(LibraryCategory categoryPressed, string typePressed) { var data = _gameManager.LibraryManager.GetLibraryData(categoryPressed, typePressed); typeInfoCanvas.SetInfo(data); exitButtonText.text = "back"; categoryPanel.selectTypeText.text = typePressed; }
public AbstractItem(LibraryCategory category, string itemName, DateTime datePrint, int copyNumber, string publisher) { isbn = Guid.NewGuid(); Category = category; _itemName = itemName; _datePrint = datePrint; _copyNumber = copyNumber; _publisher = publisher; IsBorrowed = false; }
public void DeleteCategory(LibraryCategory category) { if (IsLocked) { throw new InvalidOperationException($"Cannot delete category {category.Name} because library {Name} is locked."); } RecordUndo("delete category"); _db.DeleteCategory(category); SaveLibrary(); }
public void SetCategory(LibraryAsset asset, LibraryCategory category) { if (IsLocked) { throw new InvalidOperationException($"Cannot assign category {category.Name} because library {Name} is locked."); } RecordUndo("assign category"); _db.SetCategory(asset, category); SaveLibrary(); }
public void RenameCategory(LibraryCategory category, string newName) { if (IsLocked) { throw new InvalidOperationException($"Cannot rename category {category.Name} because library {Name} is locked."); } RecordUndo("rename category"); _db.RenameCategory(category, newName); SaveLibrary(); }
CategoryButton GetButtonByType(LibraryCategory cat) { foreach (var item in _categoryBtns) { if (item.category == cat) { return(item); } } return(null); }
public LibraryCategoryTypeInfoDef GetLibraryData(LibraryCategory cat, string type) { foreach (var item in _dict[cat].list) { if (item.type == type) { return(item); } } return(new LibraryCategoryTypeInfoDef()); }
public void SetDisabled() { if (_currentSelected != LibraryCategory.None) { GetButtonByType(_currentSelected).Unselect(); } _currentSelected = LibraryCategory.None; selectCategoryText.enabled = true; selectTypeText.enabled = false; }
public bool AddAsset(Object obj, LibraryCategory category) { if (IsLocked) { throw new InvalidOperationException($"Cannot add new asset because library {Name} is locked."); } RecordUndo("add asset to library"); var wasAdded = _db.AddAsset(obj, category); SaveLibrary(); return(wasAdded); }
/// <summary> /// 创建库类型属性实例 /// </summary> public TestflowCategoryAttribute(LibraryCategory category) { I18NOption i18NOption = new I18NOption(Assembly.GetAssembly(this.GetType()), "i18n_userlib_zh", "i18n_userlib_en") { Name = Constants.I18nName }; I18N.InitInstance(i18NOption); I18N i18N = I18N.GetInstance(Constants.I18nName); this.Category = category; this.CategoryString = i18N.GetStr(category.ToString()); }
/// <summary> /// 创建库类型属性实例 /// </summary> /// <param name="categoryString"></param> public TestflowCategoryAttribute(string categoryString) { I18NOption i18NOption = new I18NOption(Assembly.GetAssembly(this.GetType()), "i18n_userlib_zh", "i18n_userlib_en") { Name = Constants.I18nName }; I18N.InitInstance(i18NOption); I18N i18N = I18N.GetInstance(Constants.I18nName); this.CategoryString = i18N.GetStr(categoryString) ?? categoryString; Category = LibraryCategory.Miscellaneous; }
public LibraryCategory FindLibraryCategory(string LibraryCategoryGuid) { foreach (Inventory inv in m_invs) { LibraryCategory lt = FindObjectByGuid(LibraryCategoryGuid, inv.LibraryCategories) as LibraryCategory; if (lt != null) { return(lt); } } return(null); }
public string GetFormattedBreadCrumb(LibraryCategory category, IList <LibraryCategory> allCategories = null, string separator = ">>", int languageId = 0) { var result = string.Empty; var breadcrumb = GetCategoryBreadCrumb(category, allCategories, true); for (var i = 0; i <= breadcrumb.Count - 1; i++) { var categoryName = _localizationService.GetLocalized(breadcrumb[i], x => x.Name, languageId); result = string.IsNullOrEmpty(result) ? categoryName : $"{result} {separator} {categoryName}"; } return(result); }
public virtual void Init(string type, LibraryCategory cat, Action <LibraryCategory, string> OnPressedCallback, GameManager gm) { Sprite sprite = gm.LoadedAssets.GetSpriteByName(type); if (sprite != null) { typeImage.sprite = sprite; } _type = type; typeText.text = _type; _fromCategory = cat; _btn = GetComponentInChildren <Button>(); _btn.onClick.AddListener(() => OnPressedCallback(_fromCategory, _type)); }
/// <summary> /// Get the feature association for a given library category. A feature association determines /// weather a category is associated with a feature and if the feature is selected by the user. /// </summary> /// <param name="lc"></param> /// <returns></returns> private FeatureAssociation GetFeatureAssociation(LibraryCategory lc) { // default to true if there are no assocations for this library category (so the user must choose the library) FeatureAssociation assoc = FeatureAssociation.None; foreach (MFComponent comp in lc.FeatureAssociations) { TreeNode [] nodes = tv_FeatureView.Nodes.Find(comp.Guid.ToLower(), true); if (nodes.Length != 0) { if (nodes[0].Checked) { assoc = FeatureAssociation.Selected; break; } else { assoc = FeatureAssociation.NotSelected; } } else { Feature feat = m_helper.FindFeature(comp.Guid); if (feat != null) { if (m_pcdAll.Proj.ContainsFeature(comp)) { assoc = FeatureAssociation.Selected; } else { assoc = feat.Required ? FeatureAssociation.Selected : FeatureAssociation.NotSelected; } } else { assoc = FeatureAssociation.NotSelected; } } } return(assoc); }
/// <summary> /// Apply user "check/uncheck" to all project nodes if "All Projects" is selected, otherwise /// just to the selected project. /// </summary> /// <param name="pcdAll"></param> /// <param name="compGuid"></param> /// <param name="fAdd"></param> private void ApplyToAllProjects(ProjectComboData pcd, MFComponent comp, bool fCheck) { ApplyToProject(pcd, comp, fCheck, null, null); if (pcd == m_pcdAll) { foreach (ProjectComboData pcd2 in cbProjectSelect_Library.Items) { if (pcd2 != pcd) { // change the component to a bootloader component if it exists if (pcd2.Proj.IsBootloaderProject()) { Library lib = m_helper.FindLibrary(comp); if (lib != null && lib.HasLibraryCategory) { LibraryCategory lc = m_helper.FindLibraryCategory(lib.LibraryCategory.Guid); if (lc != null) { foreach (Library li in m_helper.GetLibrariesOfType(lc)) { if (li.IsBootloaderLibrary()) { comp = new MFComponent(MFComponentType.Library, li.Name, li.Guid, li.ProjectPath, comp.Conditional); break; } } } } } ApplyToProject(pcd2, comp, fCheck, null, null); } } } else if (pcd.Name.ToLower() == "tinyclr") { ApplyToProject(m_pcdAll, comp, fCheck, null, null); } }
/// <summary> /// Adds a "Generate Template" node to the library category node if supported /// </summary> /// <param name="pcd"></param> /// <param name="lc"></param> private Library AddGenerateTemplateNode(ProjectComboData pcd, LibraryCategory lc) { // There are no CLR or Support libraries that can be overriden if (lc.Level != LibraryLevel.CLR && (lc.Templates.Count > 0)) { Library lib = null; string key = lc.Guid.ToLower(); // Since each project may have its own set of libraries (and generate template nodes) // we need to synchronize the component guids for like categories if (m_lcGuidToGenGuid.ContainsKey(key)) { lib = m_lcGuidToGenGuid[key]; } else { lib = new Library(); lib.Name = c_GenerateTemplateString; lib.Level = lc.Level; lib.Description = "Generates template code in your solution's DeviceCode directory for the given Library Category." + "The project will be generated in Solutions\\" + m_solution.Name + "\\DeviceCode\\" + lc.Name; lib.LibraryCategory = new MFComponent(MFComponentType.LibraryCategory, lc.Name, lc.Guid, lc.ProjectPath); m_lcGuidToGenGuid[key] = lib; } lib.ProjectPath = m_spoClientPath + "\\Solutions\\" + m_solution.Name + "\\DeviceCode\\" + lc.Name + "\\dotnetmf.proj"; // add the library to the inventory if (null == m_helper.FindLibrary(lib.Guid)) { m_helper.AddLibraryToInventory(lib, false, m_inv); } return(lib); } return(null); }
public void InsertCategory(LibraryCategory category) { if (category == null) { throw new ArgumentNullException(nameof(category)); } if (category is IEntityForCaching) { throw new ArgumentException("Cacheable entities are not supported by Entity Framework"); } _categoryRepository.Insert(category); //cache _cacheManager.RemoveByPattern(NopLibraryDefaults.CategoriesPatternCacheKey); _staticCacheManager.RemoveByPattern(NopLibraryDefaults.CategoriesPatternCacheKey); //event notification _eventPublisher.EntityInserted(category); }
void OnCategoryButtonPressed(LibraryCategory cat) { if (_currentSelected != cat) { if (_currentSelected != LibraryCategory.None) { GetButtonByType(_currentSelected).Unselect(); } var btn = GetButtonByType(cat); btn.Select(); if (!selectTypeText.IsActive())//is checking go and component so idk if this can be triggered { selectCategoryText.enabled = false; selectTypeText.enabled = true; } _currentSelected = cat; } OnCategoryPressed(_currentSelected); }