Esempio n. 1
0
        /// <summary>
        /// Returns the only instance of MediaLibrary
        /// </summary>
        public static MediaLibrary GetInstance()
        {
            MediaLibrary strongReference = (MediaLibrary)_instance.Target;
            if (strongReference == null)
            {
                lock (_lock)
                {
                    if (strongReference == null)
                    {
                        strongReference = new MediaLibrary();
                        _instance = new WeakReference(strongReference);
                    }
                }
            }

            return strongReference;
        }
        public MainWindow()
        {
            if (!File.Exists(MediaLibrary.GetInstance().ConnectionString))
            {
                SQLiteConnection.CreateFile(MediaLibrary.GetInstance().ConnectionString);
                _library = MediaLibrary.GetInstance();
                MediaLibrary.GetInstance().Initialize();
            }
            else
                _library = MediaLibrary.GetInstance();

            _controller = MediaController.GetInstance();

            InitializeComponent();

            GenerateSongList();

            timer = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 1);
            timer.Tick += timer_Tick;
            timer.Start();
        }