internal int Compare(Genre one, Genre two)
        {
            if (one == two)
                return 0;

            if ((one.IsEmpty) || (two.IsEmpty))
                return int.MaxValue;

            return _Dic.FindOrCreateEntity(new SimpleCouple<Genre>(one, two), c => one.ComputeCompare(two));
        }
Esempio n. 2
0
        private Album(AlbumDescriptorDecorator add, bool InjectImages=false)
            : this(add.ImportContext)
        {
            _Name = add.CorrectName;
            _Genre = add.MainGenre;

            _TracksNumber = add.TracksNumber;
            _DateAdded = DateTime.Now;
            _Year = add.Year;
            _Maturity = add.Maturity;

            CDIDs = add.IDs;

            if (InjectImages)
                this.ImportImageFromDescriptor(add.Wrapped as IFullAlbumDescriptor);

            if (add.Artists != null)
            {
                ArtistHandler.ModelCollection.AddCollection(add.Artists);
            }

            
        }
Esempio n. 3
0
 private Genre(string iName, Genre iFather, IInternalMusicSession msi)
 {
     _Name = iName;
     _Father = iFather;
     msi.Genres.Register(this);
  }
Esempio n. 4
0
 private Genre(string iName, IInternalMusicSession msi)
 {
     _Name = iName;
     _Father = null;
     _Session = msi;
  }
Esempio n. 5
0
        public int ComputeCompare(Genre other)
        {
            Genre realo = other as Genre;

            if (realo == null)
                return int.MaxValue;

            if (realo == this)
                return 0;

            var Yours = realo.Fathers;

            IGenre commun = Fathers.Intersect(Yours).FirstOrDefault();

            if (commun == null)
                return int.MaxValue;

            return (Fathers.Index(commun) + Yours.Index(commun));
        }
Esempio n. 6
0
        private Genre PrivateAddSubGenre(string iName)
        {
            string newname = iName.TitleLike();

            if (_Genres == null)
                _Genres = new  List<Genre>();
            else
            {
                var res = (from g in _Genres where g.Name == newname select g).ToList();
                if (res.Count > 1)
                    throw new Exception("Algo error");
                if (res.Count == 1)
                    return res[0];
            }

            Genre novo = new Genre(newname, this, _Session);
            GenresHandler.ModelCollection.Add(novo);
            //_Genres.Add(novo);
            return novo;
        }
Esempio n. 7
0
        static internal Genre GetGenre(string name, IInternalMusicSession Session, bool iCreateIfNecessary)
        {
            if (name == null)
                return null;

            if (!iCreateIfNecessary)
                return Session.Genres.Find(name);


            Eplucheur epl = new Eplucheur(name);
            Genre MySelfOrFather = null;

            foreach(string st in epl.Depile())
            {
                MySelfOrFather = Session.Genres.Find(st);
                if (MySelfOrFather != null)
                    break;
            }

            foreach(string st in epl.Rempile())
            {
                if (MySelfOrFather == null)
                {
                    MySelfOrFather = new Genre(st, null, Session);
                }
                else
                    MySelfOrFather =  MySelfOrFather.PrivateAddSubGenre(st);
            }

            return MySelfOrFather;
        }
Esempio n. 8
0
        static internal Genre CreateDummy(IInternalMusicSession Session)
        {
            if (_Dummy == null)
            {
                _Dummy = new Genre(string.Empty, Session);
            }

            return _Dummy;
        }
 internal void Register(Genre genre)
 {
     _AllGenres.Register(genre);
     _Genres.Add(genre);
     genre.Session = Session;
 }