internal StandardBuilder(DBtype type, MusicFolderHelper iPath, ManualSettings ism, Nullable<bool> CDBOOpen)
 {
     _Type = type;
     _Folders = iPath;
     _FromSetting = (ism == null);
     _ISM = ism ?? SettingsBuilder.FromUserSetting();
     DBCleanOnOpen = CDBOOpen;
     _NeedToSerialize = true;
 }
Ejemplo n.º 2
0
        private async Task InitializeApp()
        {
            var themeManager = Resources["ThemeManager"] as ThemeManager;

            MusicFolderHelper.InitalizeMusicFolderAsync();

            var viewModelLocator = ViewModelLocator.Instance;
            await viewModelLocator.PlayerViewModel.InitializeAsync();

            await viewModelLocator.MediaLibraryViewModel.InitializeAsync();
        }
 internal StandardBuilder(DBtype type, MusicFolderHelper iPath, ManualSettings ism)
     : this(type, iPath, ism, true)
 {
 }
 static internal ISessionBuilder FromSettings()
 {
     MusicFolderHelper mfh = new MusicFolderHelper();
     return CreateSessionBuilder(mfh, () => new StandardBuilder(DBtype.SQLite, mfh, null));
 }
 static internal ISessionBuilder GetSessionBuilder(DBtype iType, ManualSettings ism = null, string RootPath = null)
 {
     MusicFolderHelper mfh = new MusicFolderHelper(RootPath);
     return CreateSessionBuilder(mfh, () => new StandardBuilder(iType, mfh, ism));
 }
        static private ISessionBuilder CreateSessionBuilder(MusicFolderHelper mfh, Func<ISessionBuilder> Create)
        {
            StandardBuilder Fromstream = GetFromFile(mfh);
            if (Fromstream != null)
            {
                Fromstream.Folders = mfh;
                Fromstream.Check();
                return Fromstream;
            }

            return Create();
        }
        static private StandardBuilder GetFromFile(MusicFolderHelper mfh)
        {
            try
            {
                using (TimeTracer.TimeTrack("Load Nhibernate config file"))
                {
                    string ffile = Path.Combine(mfh.Root, FileName);
                    if (!File.Exists(ffile))
                        return null;

                    IFormatter formatter = new BinaryFormatter();

                    using (FileStream s = File.OpenRead(ffile))
                    {
                        StandardBuilder cfg = (StandardBuilder)formatter.Deserialize(s);
                        return cfg;
                    }
                }

            }
            catch (Exception e)
            {
                Trace.WriteLine(string.Format("Problem while Reading Nhibernate cfg {0}", e));
                return null;
            }
        }