private void OnEditCategoryCommand(CategoryWrapper category) { if (category == null) { return; } _categoryDetailViewModel.Open(category.Model); }
public static void Init(CategoryWrapper parent) { var intermediate = parent.CreateEmptySubCategory("PerfCounterTest", "description"); _singleInstance = intermediate.CreateSubCategory <TestSingleInstanceCategory>("SingleInstanceCategory", "for tests"); _multiInstance = intermediate.CreateSubCategory <TestMultiInstanceCategory>(); //InitializeCountersInAssembly(intermediate, typeof(int).Assembly); }
/// <summary> /// Инициализировать счётчики в других сборках как дочерние /// </summary> /// <param name="category">Родительская категория</param> /// <param name="type">Тип из сборки для сканирования</param> /// <returns>Число классов, которые были проинициализированы</returns> public static int PassForInitializationToAssembly(this CategoryWrapper category, Type type) { if (category == null) { throw new ArgumentNullException("category"); } if (type == null) { throw new ArgumentNullException("type"); } return(InitializeCategoryWrapper(category, type.Assembly)); }
public async Task EditCategory(CategoryWrapper category, string name) { try { category.Name = name; await _CatalogueDb.SaveChangesAsync(); await LoadData(); } catch (Exception e) { Debug.WriteLine($"Error editing category: {e.Message}"); } }
/// <summary> /// Инициализировать счётчики в других сборках как дочерние /// </summary> /// <param name="category">Родительская категория</param> /// <param name="assembly">Сборки для сканирования</param> /// <returns>Число классов, которые были проинициализированы</returns> public static int PassForInitializationToAssembly(this CategoryWrapper category, params Assembly[] assembly) { if (category == null) { throw new ArgumentNullException("category"); } if (assembly == null) { throw new ArgumentNullException("assembly"); } return(InitializeCategoryWrapper(category, assembly)); }
/// <summary> /// Инициализировать счётчики в других сборках как дочерние /// </summary> /// <param name="category">Родительская категория</param> /// <param name="types">Типы из сборок для сканирования</param> /// <returns>Число классов, которые были проинициализированы</returns> public static int PassForInitializationToAssembly(this CategoryWrapper category, params Type[] types) { if (category == null) { throw new ArgumentNullException("category"); } if (types == null) { throw new ArgumentNullException("types"); } return(InitializeCategoryWrapper(category, types.Select(o => o.Assembly))); }
internal static CategoryWrapper GetInstance() { Category real = default(Category); RealInstanceFactory(ref real); var instance = (CategoryWrapper)CategoryWrapper.GetWrapper(real); InstanceFactory(ref instance); if (instance == null) { Assert.Inconclusive("Could not Create Test Instance"); } return(instance); }
private void InitializeCategories(ICollection <Category> categories) { foreach (var wrapper in Categories) { wrapper.PropertyChanged -= Wrapper_PropertyChanged; } Categories.Clear(); foreach (var category in categories) { var wrapper = new CategoryWrapper(category); Categories.Add(wrapper); wrapper.PropertyChanged += Wrapper_PropertyChanged; } }
private void OnAddCategoryExecute(int?obj) { Int32.TryParse(obj.ToString(), out int CategoryId); if (CategoryId != 0) { var category = _repository.GetCategoryById(CategoryId); var wrapper = new CategoryWrapper(category); Categories.Add(wrapper); wrapper.PropertyChanged += Wrapper_PropertyChanged; ArchiveEntity.Model.Categories.Add(wrapper.Model); HasChanges = ArchiveEntity != null && !ArchiveEntity.HasErrors; } InvalidateCommands(); }
public async Task AddSubCategory(CategoryWrapper category, string name) { try { _CatalogueDb.Categories.Add(new Data.Category(name) { ParentCategory = category.Category, ParentCategoryId = category.Category.Id }); await _CatalogueDb.SaveChangesAsync(); await LoadData(); } catch (Exception e) { Debug.WriteLine($"Error creating new sub category: {e.Message}"); } }
private void OnDeleteCategoryToEntityExecute(int?id) { int CategoryKey = (int)id; CategoryWrapper categoryW = ArchiveEntity.Categories.Where(x => x.CategoryKey == CategoryKey).First(); var result = MessageDialogService.ShowOKCancelDialog($"Удалить Категорию {categoryW.CategoryTitle}?", $"Удалить Категорию {categoryW.CategoryTitle}?"); if (result == MessageDialogResult.OK) { if (categoryW != null) { ArchiveEntity.Categories.Remove(categoryW); categoryW.PropertyChanged -= Wrapper_PropertyChanged; var wrapper = Categories.Where(x => x.CategoryKey == CategoryKey).First(); Categories.Remove(wrapper); _repository.RemoveCategory(ArchiveEntity.ArchiveEntityKey, CategoryKey); HasChanges = ArchiveEntity != null && !ArchiveEntity.HasErrors; } } /* * if (await _repository.HasMeetingAsync(Test.TestKey)) * { * await MessageDialogService.ShowInfoDialogAsync("!!!"); * return; * } * * var result = await MessageDialogService.ShowOKCancelDialogAsync("?", "title"); * * if (result == MessageDialogResult.OK) * { * _repository.Remove(Test.Model); * await _repository.SaveAsync(); * RaiseDetailDelitedEvent(Test.TestKey); * * } * */ // RemoveItemFromEntityCollection(_fileOnDriveDataProvider.RemoveCategoryFromEntity, CategoryKey); }
public static void AddCategory(string sheetName) { Logger.WriteToLogFile(Utilities.GetCurrentMethod()); Excel.Worksheet sheet = ExcelController.GetWorkSheet(sheetName); Excel.Range usedRange = sheet.UsedRange; CategoryRoot objcategoryRoot = new CategoryRoot(); CategoryWrapper objWrap = new CategoryWrapper(); //Do not consider row 1 as its the header for (int Row = 2; Row <= usedRange.Rows.Count; Row++) { Category objCategory = new Category(); for (int Col = 1; Col <= usedRange.Columns.Count; Col++) { string name = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2; dynamic dValue = (usedRange.Cells[Row, Col] as Excel.Range).Value2; string value = null; if (dValue != null) { value = dValue.ToString(); } else { continue; } ExcelUtilities.PopulateStructure <Category>(name, value, ref objCategory); } //Add the country in the Neo4j Database objWrap.objCategoryRoot = objcategoryRoot; objWrap.objCategory = objCategory; DBAddinterface.CreateCategoryNode(objCategory); } }
/// <summary> /// Builds the category list and calculates SubCategoryPositions /// </summary> private ObservableCollection <CategoryWrapper> BuildCategoriesList(List <Data.Category> categories) { // Group categories by their parent Ids Dictionary <int, List <Data.Category> > categoriesByParentId = categories .GroupBy(c => c.ParentCategoryId ?? -1) .ToDictionary(g => g.Key, g => g.ToList()); // Builds category list recursively for a parent category List <CategoryWrapper> BuildSubList(CategoryWrapper?parentCategory) { // Get sub categories List <CategoryWrapper> wrappers = new List <CategoryWrapper>(); if (!categoriesByParentId.TryGetValue(parentCategory?.Category?.Id ?? -1, out List <Data.Category> subCategories) || (subCategories?.Count ?? 0) < 1) { return(wrappers); } // Calculate positions ordered by name List <Data.Category> orderedSubCategories = subCategories.OrderBy(c => c.Name).ToList(); for (int i = 0; i < orderedSubCategories.Count; i++) { CategoryWrapper wrapper = new CategoryWrapper(orderedSubCategories[i]); wrapper.ParentCategory = parentCategory; wrapper.SubCategoryPosition = (parentCategory == null) ? SubCategoryPosition.None : (i == 0 && orderedSubCategories.Count > 1) ? SubCategoryPosition.Start : (i < orderedSubCategories.Count - 1) ? SubCategoryPosition.Middle : SubCategoryPosition.End; wrappers.Add(wrapper); // Calculate positions of its sub categories (recursive) wrappers.AddRange(BuildSubList(wrapper)); } return(wrappers); } // Build/Start for main categories (no parents) return(new ObservableCollection <CategoryWrapper>(BuildSubList(null))); }
public async Task DeleteCategory(CategoryWrapper category) { try { IEnumerable <Data.Item> items = _CatalogueDb.Items.Where(i => i.CategoryId == category.Category.Id); foreach (Data.Item item in items) { item.CategoryId = null; item.Category = null; } _CatalogueDb.Categories.Remove(category.Category); await _CatalogueDb.SaveChangesAsync(); await LoadData(); } catch (Exception e) { Debug.WriteLine($"Error deleting category: {e.Message}"); } }
public IActionResult SingleCategory(int categoryId) { var CategoryWithProducts = db.Categories .Include(c => c.Products) .ThenInclude(a => a.Product) .FirstOrDefault(c => c.CategoryId == categoryId); List <Product> AllProducts = db.Products .Include(p => p.Categories) .ThenInclude(a => a.Category) .Where(p => p.Categories.All(a => a.Category.CategoryId == categoryId)).ToList(); CategoryWrapper SingleCategory = new CategoryWrapper(); SingleCategory.Category = CategoryWithProducts; SingleCategory.AllProductsForCategory = AllProducts; return(View("SingleCategory", SingleCategory)); }
/// <summary> /// Выполнить инициализацию счётчиков путём вызова метода и передачи category /// </summary> /// <param name="method">Метод инициализации</param> /// <param name="category">Категория</param> private static void InitPerfCountersWrapper(MethodInfo method, CategoryWrapper category) { var allParams = method.GetParameters(); object[] parameters = new object[allParams.Length]; for (int i = 0; i < parameters.Length; i++) { if (allParams[i].ParameterType == typeof(CategoryWrapper)) { parameters[i] = category; } else { throw new ArgumentException("Bad method description"); } } method.Invoke(null, parameters); }
/// <summary> /// Инициализировать счётчики в сборке (для обёрток). /// Ищет все типы, унаследованные от PerfCountersContainer или от CategoryWrapper или помеченные атрибутом PerfCountersContainerAttribute и /// содержащие метод инициализации, помеченный атрибутом PerfCountersInitializationMethodAttribute /// </summary> /// <param name="category">Родительская категория</param> /// <param name="assembly">Сборка для сканирования</param> /// <returns>Число классов, которые были проинициализированы</returns> public static int InitializeCategoryWrapper(CategoryWrapper category, Assembly assembly) { if (category == null) { throw new ArgumentNullException("category"); } if (assembly == null) { throw new ArgumentNullException("assembly"); } var allInitMethods = FindAllPerfCountersInAsmForWrapper(assembly).Select(o => ExtractInitializationMethodForWrapper(o)).Where(o => o != null).ToList(); foreach (var elem in allInitMethods) { InitPerfCountersWrapper(elem, category); } return(allInitMethods.Count); }
/// <summary> /// Инициализировать счётчики в сборках (для обёрток). /// Ищет все типы, унаследованные от PerfCountersContainer или от CategoryWrapper или помеченные атрибутом PerfCountersContainerAttribute и /// содержащие метод инициализации, помеченный атрибутом PerfCountersInitializationMethodAttribute /// </summary> /// <param name="category">Родительская категория</param> /// <param name="assembly">Перечень сборок</param> /// <returns>Число классов, которые были проинициализированы</returns> public static int InitializeCategoryWrapper(CategoryWrapper category, IEnumerable <Assembly> assembly) { if (category == null) { throw new ArgumentNullException("category"); } if (assembly == null) { throw new ArgumentNullException("assembly"); } int res = 0; foreach (var asm in assembly) { res += InitializeCategoryWrapper(category, asm); } return(res); }
public static void Init(CategoryWrapper root) { DistributorCounters.Init(root); }
public static void Init(CategoryWrapper root) { WriterCounters.Init(root); }
public static void Init(CategoryWrapper wrapper) { _instance = wrapper.CreateSubCategory <WriterCounters>(); }
static partial void InstanceFactory(ref CategoryWrapper instance, [CallerMemberName] string callerName = "");
public static void Init(CategoryWrapper wrapper) { _instance = wrapper.CreateSubCategory <AttributeCounters>(); MultyCategory.Init(_instance); }
public static void Init(CategoryWrapper wrapper) { _instance = wrapper.CreateSubCategory <MultyCategory>(); }
public static void Init(CategoryWrapper root) { ProxyCounters.Init(root); }