Exemplo n.º 1
0
        public static Videotheque Load(string videothequeFileName, IVideothequeLoadingUI ui, bool ignoreExternalSoftware, string customProgramFolder = null)
        {
            ui = new LoadingUIDecorator(ui);
            Videotheque v = new Videotheque();

            if (customProgramFolder == null)
            {
                v.ProgramFolder = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory;
            }
            else
            {
                v.ProgramFolder = new DirectoryInfo(customProgramFolder);
            }
            v.Locations = new VideothequeLocations(v);
            try
            {
                if (!ignoreExternalSoftware)
                {
                    v.LoadBuiltInSoftware(ui);
                    v.LoadExternalReferences(ui);
                    v.SaveStartupFile();
                }
                else
                {
                    v.StartupSettings = new VideothequeStartupSettings();
                }

                v.LoadVideotheque(videothequeFileName, ui);
                var fname = v.VideothequeSettingsFile.FullName;
                if (v.StartupSettings.LastLoadedProjects.Contains(fname))
                {
                    v.StartupSettings.LastLoadedProjects.Remove(fname);
                }
                v.StartupSettings.LastLoadedProjects.Insert(0, fname);
                v.SaveStartupFile();

                v.CheckSubdirectories(ui);
                v.Save();


                v.LoadBinaryHashes(ui);
                v.LoadContainers(ui);
                v.CreateModels(ui);
                v.CheckGUIDCorrectness(ui);


                ui.ExitSuccessfully();
                return(v);
            }
            catch (LoadingException)
            {
                return(null);
            }
        }