public BinderCoverVM(Binder binder, AnimationStarter animationStarter) { if (binder == null) throw new ArgumentNullException("BinderCoverVM ctor: binder may not be null"); if (animationStarter == null) throw new ArgumentNullException("BinderCoverVM ctor: animationStarter may not be null"); _binder = binder; RaisePropertyChanged_UI(nameof(Binder)); _metaBriefcase = MetaBriefcase.OpenInstance; if (_metaBriefcase == null) throw new ArgumentNullException("BinderCoverVM ctor: MetaBriefcase may not be null"); RaisePropertyChanged_UI(nameof(MetaBriefcase)); _animationStarter = animationStarter; }
internal static MetaBriefcase Merge(MetaBriefcase one, MetaBriefcase two) { if (one?.Categories == null || one?.FieldDescriptions == null) return two; if (two?.Categories == null || two?.FieldDescriptions == null) return one; foreach (var fdOne in one.FieldDescriptions) { var fdTwo = two.FieldDescriptions.FirstOrDefault(fd => fd.Id == fdOne.Id); if (fdTwo != null) { foreach (var pvOne in fdOne.PossibleValues.Where(pv1 => fdTwo.PossibleValues.All(pv2 => pv2.Id != pv1.Id))) { fdTwo.PossibleValues.Add(pvOne); } } } foreach (var fdTwo in two.FieldDescriptions) { var fdOne = one.FieldDescriptions.FirstOrDefault(fd => fd.Id == fdTwo.Id); if (fdOne != null) { foreach (var pvTwo in fdTwo.PossibleValues.Where(pv2 => fdOne.PossibleValues.All(pv1 => pv1.Id != pv2.Id))) { fdOne.PossibleValues.Add(pvTwo); } } } foreach (var catOne in one.Categories) { var catTwo = two.Categories.FirstOrDefault(cat => cat.Id == catOne.Id); if (catTwo != null) { foreach (var fdOne in catOne.FieldDescriptionIds.Where(fd1 => catTwo.FieldDescriptionIds.All(fd2 => fd2 != fd1))) { catTwo.FieldDescriptionIds.Add(fdOne); } } } foreach (var catTwo in two.Categories) { var catOne = one.Categories.FirstOrDefault(cat => cat.Id == catTwo.Id); if (catOne != null) { foreach (var fdTwo in catTwo.FieldDescriptionIds.Where(fd2 => catOne.FieldDescriptionIds.All(fd1 => fd1 != fd2))) { catOne.FieldDescriptionIds.Add(fdTwo); } } } foreach (var fdInOne in one.FieldDescriptions.Where(fd1 => two.FieldDescriptions.All(fd2 => fd2.Id != fd1.Id && fd2.Caption != fd1.Caption))) { two.FieldDescriptions.Add(fdInOne); } foreach (var fdInTwo in two.FieldDescriptions.Where(fd2 => one.FieldDescriptions.All(fd1 => fd1.Id != fd2.Id && fd1.Caption != fd2.Caption))) { one.FieldDescriptions.Add(fdInTwo); } foreach (var fdInOne in one.FieldDescriptions) { var fdInTwo = two.FieldDescriptions.FirstOrDefault(fd => fd.Id == fdInOne.Id); if (fdInTwo != null) { bool isAnyValueAllowedTolerant = fdInOne.IsAnyValueAllowed || fdInTwo.IsAnyValueAllowed; fdInOne.IsAnyValueAllowed = fdInTwo.IsAnyValueAllowed = isAnyValueAllowedTolerant; } } foreach (var catInOne in one.Categories.Where(cat1 => two.Categories.All(cat2 => cat2.Id != cat1.Id && cat2.Name != cat1.Name))) { two.Categories.Add(catInOne); } foreach (var catInTwo in two.Categories.Where(cat2 => one.Categories.All(cat1 => cat1.Id != cat2.Id && cat1.Name != cat2.Name))) { one.Categories.Add(catInTwo); } return one; }
internal static MetaBriefcase GetInstance(RuntimeData runtimeData, Briefcase briefcase) { lock (_instanceLocker) { if (_instance == null) { _instance = new MetaBriefcase(runtimeData, briefcase); } return _instance; } }
private bool CopyXMLPropertiesFrom(MetaBriefcase source) { if (source == null) return false; //IsElevated = source._isElevated; // NO! FieldDescription.Copy(source._fieldDescriptions, ref _fieldDescriptions); RaisePropertyChanged_UI(nameof(FieldDescriptions)); Category.Copy(source._categories, ref _categories, _fieldDescriptions); RaisePropertyChanged_UI(nameof(Categories)); CurrentCategoryId = source._currentCategoryId; // must come after setting the categories UpdateCurrentCategory2(); CurrentFieldDescriptionId = source._currentFieldDescriptionId; // must come after setting the current category UpdateCurrentFieldDescription2(); return true; }
internal MetaBriefcaseRubbishBin(MetaBriefcase metaBriefcase) { _mbc = metaBriefcase; }