Beispiel #1
0
 public void UpdateFrom(StylesTreeItem treeItem)
 {
     _styleRebuildedString = treeItem._styleRebuildedString;
     if (string.IsNullOrEmpty(_styleOriginalString) || _styleOriginalString.Length < treeItem._styleOriginalString.Length)
     {
         _styleOriginalString = treeItem._styleOriginalString;
     }
 }
        protected StylesTreeItem ComputeParents(StylesTreeItem newStyle)
        {
            var computedParents = newStyle.ExtractParentStyles();
            computedParents = computedParents.OrderBy(x => x.Complexity).ToList();
            var integratedParents = computedParents.Select(GetOrCreateParent).ToList();

            newStyle.SetParents(integratedParents);
            return newStyle;
        }
Beispiel #3
0
        public bool ContentEqualsTo(StylesTreeItem item)
        {
            #region test lists count

            if (item._musicGenresIdxs.Count != _musicGenresIdxs.Count)
            {
                return(false);
            }
            if (item._subStylesIdxs.Count != _subStylesIdxs.Count)
            {
                return(false);
            }
            if (item._styleAlterationsIdxs.Count != _styleAlterationsIdxs.Count)
            {
                return(false);
            }

            #endregion

            #region test musicGenres

            foreach (var musicGenresIdx in item._musicGenresIdxs)
            {
                if (!_musicGenresIdxs.Contains(musicGenresIdx))
                {
                    return(false);
                }
            }

            #endregion

            #region test subStyles

            foreach (var subStylesIdx in item._subStylesIdxs)
            {
                if (!_subStylesIdxs.Contains(subStylesIdx))
                {
                    return(false);
                }
            }

            #endregion

            #region test styleAlterations

            foreach (var styleAlterationsIdx in item._styleAlterationsIdxs)
            {
                if (!_styleAlterationsIdxs.Contains(styleAlterationsIdx))
                {
                    return(false);
                }
            }

            #endregion

            return(true);
        }
Beispiel #4
0
        protected StylesTreeItem ComputeParents(StylesTreeItem newStyle)
        {
            var computedParents = newStyle.ExtractParentStyles();

            computedParents = computedParents.OrderBy(x => x.Complexity).ToList();
            var integratedParents = computedParents.Select(GetOrCreateParent).ToList();

            newStyle.SetParents(integratedParents);
            return(newStyle);
        }
        private void CreateStylesTreeItem(StylesTreeItem stylesTreeItem)
        {
            stylesTreeItem.ID = _idGenerator.NewID();

            Debug.Assert(!(_stylesTreeItems.Select(x => x.ID).Contains(stylesTreeItem.ID)));
            Debug.Assert(GetStylesTreeItem(stylesTreeItem) == null);

            _stylesTreeItems.Add(stylesTreeItem);

            return;
        }
Beispiel #6
0
        private void CreateStylesTreeItem(StylesTreeItem stylesTreeItem)
        {
            stylesTreeItem.ID = _idGenerator.NewID();

            Debug.Assert(!(_stylesTreeItems.Select(x => x.ID).Contains(stylesTreeItem.ID)));
            Debug.Assert(GetStylesTreeItem(stylesTreeItem) == null);

            _stylesTreeItems.Add(stylesTreeItem);

            return;
        }
        private StylesTreeItem CreateOrUpdateStylesTreeItem(StylesTreeItem stylesTreeItem)
        {
            StylesTreeItem result = stylesTreeItem;
            if (TryGetStylesTreeItem(ref result))
            {
                result.UpdateFrom(stylesTreeItem);
                return result;
            }

            CreateStylesTreeItem(stylesTreeItem);
            return stylesTreeItem;
        }
Beispiel #8
0
        private StylesTreeItem GetOrCreateParent(StylesTreeItem stylesTreeItem)
        {
            StylesTreeItem result = stylesTreeItem;

            if (!TryGetStylesTreeItem(ref result))
            {
                ComputeParents(stylesTreeItem);
                return(CreateOrUpdateStylesTreeItem(stylesTreeItem));
            }

            return(result);
        }
Beispiel #9
0
        private bool TryGetStylesTreeItem(ref StylesTreeItem stylesTreeItem)
        {
            var result = GetStylesTreeItem(stylesTreeItem);

            if (result == null)
            {
                return(false);
            }

            stylesTreeItem = result;
            return(true);
        }
Beispiel #10
0
        private StylesTreeItem CreateOrUpdateStylesTreeItem(StylesTreeItem stylesTreeItem)
        {
            StylesTreeItem result = stylesTreeItem;

            if (TryGetStylesTreeItem(ref result))
            {
                result.UpdateFrom(stylesTreeItem);
                return(result);
            }

            CreateStylesTreeItem(stylesTreeItem);
            return(stylesTreeItem);
        }
        public bool ContentEqualsTo(StylesTreeItem item)
        {
            #region test lists count

            if(item._musicGenresIdxs.Count != _musicGenresIdxs.Count)
                return false;
            if(item._subStylesIdxs.Count != _subStylesIdxs.Count)
                return false;
            if (item._styleAlterationsIdxs.Count != _styleAlterationsIdxs.Count)
                return false;

            #endregion

            #region test musicGenres

            foreach (var musicGenresIdx in item._musicGenresIdxs)
            {
                if(!_musicGenresIdxs.Contains(musicGenresIdx))
                    return false;
            }

            #endregion

            #region test subStyles

            foreach (var subStylesIdx in item._subStylesIdxs)
            {
                if (!_subStylesIdxs.Contains(subStylesIdx))
                    return false;
            }

            #endregion

            #region test styleAlterations

            foreach (var styleAlterationsIdx in item._styleAlterationsIdxs)
            {
                if (!_styleAlterationsIdxs.Contains(styleAlterationsIdx))
                    return false;
            }

            #endregion

            return true;
        }
        private StylesTreeItem GetOrCreateParent(StylesTreeItem stylesTreeItem)
        {
            StylesTreeItem result = stylesTreeItem;
            if (!TryGetStylesTreeItem(ref result))
            {
                ComputeParents(stylesTreeItem);
                return CreateOrUpdateStylesTreeItem(stylesTreeItem);
            }

            return result;
        }
        private bool TryGetStylesTreeItem(ref StylesTreeItem stylesTreeItem)
        {
            var result = GetStylesTreeItem(stylesTreeItem);
            if (result == null)
            {
                return false;
            }

            stylesTreeItem = result;
            return true;
        }
 private StylesTreeItem GetStylesTreeItem(StylesTreeItem treeItem)
 {
     return _stylesTreeItems.Where(x => x.ContentEqualsTo(treeItem)).SingleOrDefault();
 }
Beispiel #15
0
 private StylesTreeItem GetStylesTreeItem(StylesTreeItem treeItem)
 {
     return(_stylesTreeItems.Where(x => x.ContentEqualsTo(treeItem)).SingleOrDefault());
 }
 public void UpdateFrom(StylesTreeItem treeItem)
 {
     _styleRebuildedString = treeItem._styleRebuildedString;
     if (string.IsNullOrEmpty(_styleOriginalString) || _styleOriginalString.Length < treeItem._styleOriginalString.Length)
     {
         _styleOriginalString = treeItem._styleOriginalString;
     }
 }