Beispiel #1
0
 public void CreateLibrarian(Librarian newLibrarian)
 {
     _appDbContext.Librarian.Add(newLibrarian);
     _appDbContext.SaveChanges();
 }
 public FormLibrarian(Librarian source)
 {
     this.source = source;
     InitializeComponent();
 }
Beispiel #3
0
        /// <summary>
        /// Rebuild the Wixlib using the original Wixlib and updated files.
        /// </summary>
        private void RebuildWixlib()
        {
            Librarian librarian = new Librarian();
            WixVariableResolver wixVariableResolver = new WixVariableResolver();
            BlastBinderFileManager binderFileManager = new BlastBinderFileManager(this.outputFile);

            if (0 == Retina.GetCabinetFileIdToFileNameMap(this.outputFile).Count)
            {
                this.messageHandler.Display(this, WixWarnings.NotABinaryWixlib(this.outputFile));
                return;
            }

            Library library = Library.Load(this.outputFile, librarian.TableDefinitions, false, false);
            library.Save(this.outputFile, binderFileManager, wixVariableResolver);
        }
Beispiel #4
0
        /// <summary>
        /// Main running method for the application.
        /// </summary>
        /// <param name="args">Commandline arguments to the application.</param>
        /// <returns>Returns the application error code.</returns>
        private int Run(string[] args)
        {
            try
            {
                Librarian         librarian = null;
                SectionCollection sections  = new SectionCollection();

                // parse the command line
                this.ParseCommandLine(args);

                // exit if there was an error parsing the command line (otherwise the logo appears after error messages)
                if (this.messageHandler.EncounteredError)
                {
                    return(this.messageHandler.LastErrorNumber);
                }

                if (0 == this.inputFiles.Count)
                {
                    this.showHelp = true;
                }
                else if (null == this.outputFile)
                {
                    if (1 < this.inputFiles.Count)
                    {
                        throw new WixException(WixErrors.MustSpecifyOutputWithMoreThanOneInput());
                    }

                    this.outputFile = Path.ChangeExtension(Path.GetFileName(this.inputFiles[0]), ".wixlib");
                }

                if (this.showLogo)
                {
                    AppCommon.DisplayToolHeader();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(LitStrings.HelpMessage);
                    AppCommon.DisplayToolFooter();
                    return(this.messageHandler.LastErrorNumber);
                }

                foreach (string parameter in this.invalidArgs)
                {
                    this.messageHandler.Display(this, WixWarnings.UnsupportedCommandLineArgument(parameter));
                }
                this.invalidArgs = null;

                // create the librarian
                librarian          = new Librarian();
                librarian.Message += new MessageEventHandler(this.messageHandler.Display);
                librarian.ShowPedanticMessages = this.showPedanticMessages;

                if (null != this.bindPaths)
                {
                    foreach (string bindPath in this.bindPaths)
                    {
                        if (-1 == bindPath.IndexOf('='))
                        {
                            this.sourcePaths.Add(bindPath);
                        }
                    }
                }

                // load any extensions
                foreach (string extension in this.extensionList)
                {
                    WixExtension wixExtension = WixExtension.Load(extension);

                    librarian.AddExtension(wixExtension);

                    // load the binder file manager regardless of whether it will be used in case there is a collision
                    if (null != wixExtension.BinderFileManager)
                    {
                        if (null != this.binderFileManager)
                        {
                            throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, LitStrings.EXP_CannotLoadBinderFileManager, wixExtension.BinderFileManager.GetType().ToString(), this.binderFileManager.GetType().ToString()), "ext");
                        }

                        this.binderFileManager = wixExtension.BinderFileManager;
                    }
                }

                // add the sections to the librarian
                foreach (string inputFile in this.inputFiles)
                {
                    string inputFileFullPath = Path.GetFullPath(inputFile);
                    string dirName           = Path.GetDirectoryName(inputFileFullPath);

                    if (!this.sourcePaths.Contains(dirName))
                    {
                        this.sourcePaths.Add(dirName);
                    }

                    // try loading as an object file
                    try
                    {
                        Intermediate intermediate = Intermediate.Load(inputFileFullPath, librarian.TableDefinitions, this.suppressVersionCheck, this.suppressSchema);
                        sections.AddRange(intermediate.Sections);
                        continue; // next file
                    }
                    catch (WixNotIntermediateException)
                    {
                        // try another format
                    }

                    // try loading as a library file
                    Library loadedLibrary = Library.Load(inputFileFullPath, librarian.TableDefinitions, this.suppressVersionCheck, this.suppressSchema);
                    sections.AddRange(loadedLibrary.Sections);
                }

                // and now for the fun part
                Library library = librarian.Combine(sections);

                // save the library output if an error did not occur
                if (null != library)
                {
                    if (this.bindFiles)
                    {
                        // if the binder file manager has not been loaded yet use the built-in binder extension
                        if (null == this.binderFileManager)
                        {
                            this.binderFileManager = new BinderFileManager();
                        }


                        if (null != this.bindPaths)
                        {
                            foreach (string bindPath in this.bindPaths)
                            {
                                if (-1 == bindPath.IndexOf('='))
                                {
                                    this.binderFileManager.BindPaths.Add(bindPath);
                                }
                                else
                                {
                                    string[] namedPair = bindPath.Split('=');

                                    //It is ok to have duplicate key.
                                    this.binderFileManager.NamedBindPaths.Add(namedPair[0], namedPair[1]);
                                }
                            }
                        }

                        foreach (string sourcePath in this.sourcePaths)
                        {
                            this.binderFileManager.SourcePaths.Add(sourcePath);
                        }
                    }
                    else
                    {
                        this.binderFileManager = null;
                    }

                    foreach (string localizationFile in this.localizationFiles)
                    {
                        Localization localization = Localization.Load(localizationFile, librarian.TableDefinitions, this.suppressSchema);

                        library.AddLocalization(localization);
                    }

                    WixVariableResolver wixVariableResolver = new WixVariableResolver();

                    wixVariableResolver.Message += new MessageEventHandler(this.messageHandler.Display);

                    library.Save(this.outputFile, this.binderFileManager, wixVariableResolver);
                }
            }
            catch (WixException we)
            {
                this.messageHandler.Display(this, we.Error);
            }
            catch (Exception e)
            {
                this.messageHandler.Display(this, WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace));
                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            return(this.messageHandler.LastErrorNumber);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            var librarian = new Librarian();

            librarian.GetAge();
        }
Beispiel #6
0
Datei: lit.cs Projekt: zooba/wix3
        /// <summary>
        /// Main running method for the application.
        /// </summary>
        /// <param name="args">Commandline arguments to the application.</param>
        /// <returns>Returns the application error code.</returns>
        private int Run(string[] args)
        {
            try
            {
                Librarian librarian = null;
                SectionCollection sections = new SectionCollection();

                // parse the command line
                this.ParseCommandLine(args);

                // exit if there was an error parsing the command line (otherwise the logo appears after error messages)
                if (this.messageHandler.EncounteredError)
                {
                    return this.messageHandler.LastErrorNumber;
                }

                if (0 == this.inputFiles.Count)
                {
                    this.showHelp = true;
                }
                else if (null == this.outputFile)
                {
                    if (1 < this.inputFiles.Count)
                    {
                        throw new WixException(WixErrors.MustSpecifyOutputWithMoreThanOneInput());
                    }

                    this.outputFile = Path.ChangeExtension(Path.GetFileName(this.inputFiles[0]), ".wixlib");
                }

                if (this.showLogo)
                {
                    AppCommon.DisplayToolHeader();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(LitStrings.HelpMessage);
                    AppCommon.DisplayToolFooter();
                    return this.messageHandler.LastErrorNumber;
                }

                foreach (string parameter in this.invalidArgs)
                {
                    this.messageHandler.Display(this, WixWarnings.UnsupportedCommandLineArgument(parameter));
                }
                this.invalidArgs = null;

                // create the librarian
                librarian = new Librarian();
                librarian.Message += new MessageEventHandler(this.messageHandler.Display);
                librarian.ShowPedanticMessages = this.showPedanticMessages;

                if (null != this.bindPaths)
                {
                    foreach (string bindPath in this.bindPaths)
                    {
                        if (-1 == bindPath.IndexOf('='))
                        {
                            this.sourcePaths.Add(bindPath);
                        }
                    }
                }

                // load any extensions
                foreach (string extension in this.extensionList)
                {
                    WixExtension wixExtension = WixExtension.Load(extension);

                    librarian.AddExtension(wixExtension);

                    // load the binder file manager regardless of whether it will be used in case there is a collision
                    if (null != wixExtension.BinderFileManager)
                    {
                        if (null != this.binderFileManager)
                        {
                            throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, LitStrings.EXP_CannotLoadBinderFileManager, wixExtension.BinderFileManager.GetType().ToString(), this.binderFileManager.GetType().ToString()), "ext");
                        }

                        this.binderFileManager = wixExtension.BinderFileManager;
                    }
                }

                // add the sections to the librarian
                foreach (string inputFile in this.inputFiles)
                {
                    string inputFileFullPath = Path.GetFullPath(inputFile);
                    string dirName = Path.GetDirectoryName(inputFileFullPath);

                    if (!this.sourcePaths.Contains(dirName))
                    {
                        this.sourcePaths.Add(dirName);
                    }

                    // try loading as an object file
                    try
                    {
                        Intermediate intermediate = Intermediate.Load(inputFileFullPath, librarian.TableDefinitions, this.suppressVersionCheck, this.suppressSchema);
                        sections.AddRange(intermediate.Sections);
                        continue; // next file
                    }
                    catch (WixNotIntermediateException)
                    {
                        // try another format
                    }

                    // try loading as a library file
                    Library loadedLibrary = Library.Load(inputFileFullPath, librarian.TableDefinitions, this.suppressVersionCheck, this.suppressSchema);
                    sections.AddRange(loadedLibrary.Sections);
                }

                // and now for the fun part
                Library library = librarian.Combine(sections);

                // save the library output if an error did not occur
                if (null != library)
                {
                    if (this.bindFiles)
                    {
                        // if the binder file manager has not been loaded yet use the built-in binder extension
                        if (null == this.binderFileManager)
                        {
                            this.binderFileManager = new BinderFileManager();
                        }

                        if (null != this.bindPaths)
                        {
                            foreach (string bindPath in this.bindPaths)
                            {
                                if (-1 == bindPath.IndexOf('='))
                                {
                                    this.binderFileManager.BindPaths.Add(bindPath);
                                }
                                else
                                {
                                    string[] namedPair = bindPath.Split('=');

                                    //It is ok to have duplicate key.
                                    this.binderFileManager.NamedBindPaths.Add(namedPair[0], namedPair[1]);
                                }
                            }
                        }

                        foreach (string sourcePath in this.sourcePaths)
                        {
                            this.binderFileManager.SourcePaths.Add(sourcePath);
                        }
                    }
                    else
                    {
                        this.binderFileManager = null;
                    }

                    foreach (string localizationFile in this.localizationFiles)
                    {
                        Localization localization = Localization.Load(localizationFile, librarian.TableDefinitions, this.suppressSchema);

                        library.AddLocalization(localization);
                    }

                    WixVariableResolver wixVariableResolver = new WixVariableResolver();

                    wixVariableResolver.Message += new MessageEventHandler(this.messageHandler.Display);

                    library.Save(this.outputFile, this.binderFileManager, wixVariableResolver);
                }
            }
            catch (WixException we)
            {
                this.messageHandler.Display(this, we.Error);
            }
            catch (Exception e)
            {
                this.messageHandler.Display(this, WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace));
                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            return this.messageHandler.LastErrorNumber;
        }
Beispiel #7
0
        public void Initial_del_4()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Librarian lb = new Librarian("lb");

            admin.ModifyLibrarian(lb.PersonID, "lb", "lb", "lb", 2);

            SDM.CurrentUser = lb;

            lb.AddBook
            (
                "Introduction to Algorithms",
                "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
                "MIT Press",
                2009,
                "Third Edition",
                "Alghorithm techniques and design",
                5000,
                false,
                3,
                "Algorithms, Data Structures, Complexity, Computational Theory"
            );
            lb.AddBook
            (
                "Algorithms + Data Structures = Programs",
                "Niklaus Wirth",
                "Prentice Hall PTR",
                1978,
                "First Edition",
                "",
                5000,
                false,
                3,
                "Algorithms, Data Structures, Search Algorithms, Pascal"
            );
            lb.AddBook
            (
                "The Art of Computer Programming",
                "Donald E. Knuth",
                "Addison Wesley Longman Publishing Co., Inc.",
                1997,
                "Third Edition",
                "",
                5000,
                false,
                3,
                "Algorithms, Combinatorial Algorithms, Recursion"
            );
            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Algorithms + Data Structures = Programs");
            DocClass d3 = new DocClass("The Art of Computer Programming");

            lb.RegisterUser("p1", "p1", "p1", "Via Margutta, 3", "30001", false);
            lb.RegisterUser("p2", "p2", "p2", "Via Sacra, 13", "30002", false);
            lb.RegisterUser("p3", "p3", "p3", "Via del Corso, 22", "30003", false);
            lb.RegisterUser("s", "s", "s", "s", "s", false);
            lb.RegisterUser("v", "v", "v", "v", "v", false);
            Student p1 = new Student("p1");
            Student p2 = new Student("p2");
            Student p3 = new Student("p3");
            Student s  = new Student("s");
            Student v  = new Student("v");

            lb.ModifyUser(p1.PersonID, p1.Name, p1.Adress, p1.PhoneNumber, 4);
            lb.ModifyUser(p2.PersonID, p2.Name, p2.Adress, p2.PhoneNumber, 4);
            lb.ModifyUser(p3.PersonID, p3.Name, p3.Adress, p3.PhoneNumber, 4);
            lb.ModifyUser(v.PersonID, v.Name, v.Adress, v.PhoneNumber, 3);

            Debug.Assert(SDM.LMS.GetDoc(d1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(d2.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(d3.ID) != null);

            Debug.Assert(d1.Quantity == 3);
            Debug.Assert(d2.Quantity == 3);
            Debug.Assert(d3.Quantity == 3);

            Debug.Assert(SDM.LMS.GetUser(p1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p3.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(s.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(v.PersonID) != null);
        }
        public Librarian Login(string username, string password)
        {
            Librarian librarian = _libraryContext.Librarians.FirstOrDefault(l => l.Username == username && l.Password == password);

            return(librarian);
        }
Beispiel #9
0
        public void Test11()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Librarian lb = new Librarian("lb");

            admin.ModifyLibrarian(lb.PersonID, "lb", "lb", "lb", 2);

            lb.AddBook
            (
                "Introduction to Algorithms",
                "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
                "MIT Press",
                2009,
                "Third Edition",
                "Alghorithm techniques and design",
                1800,
                false,
                3,
                ""
            );
            lb.AddBook
            (
                "Design Patterns: Elements of Reusable Object-Oriented Software",
                "Erich Gamma, Ralph Johnson, John Vlissides, Richard Helm",
                "Addison-Wesley Professional",
                2003,
                "First Edition",
                "Programm patterns, how to programm well w/o headache",
                2000,
                true,
                2,
                ""
            );
            lb.AddBook
            (
                "The Mythical Man-month",
                "Brooks,Jr., Frederick P",
                "Addison-Wesley Longman Publishing Co., Inc.",
                1995,
                "Second edition",
                "How to do everything and live better",
                800,
                false,
                1,
                ""
            );
            lb.AddAV("Null References: The Billion Dollar Mistake", "Tony Hoare", 400, 1, "");
            lb.AddAV("Information Entropy", "Claude Shannon", 700, 1, "");
            DocClass b1  = new DocClass("Introduction to Algorithms");
            DocClass b2  = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");
            DocClass b3  = new DocClass("The Mythical Man-month");
            DocClass av1 = new DocClass("Null References: The Billion Dollar Mistake");
            DocClass av2 = new DocClass("Information Entropy");

            lb.RegisterUser("Sergey Afonso", "Sergey Afonso", "Sergey Afonso", "Via Margutta, 3", "30001", false);
            lb.RegisterUser("Nadia Teixeira", "Nadia Teixeira", "Nadia Teixeira", "Via Sacra, 13", "30002", false);
            lb.RegisterUser("Elvira Espindola", "Elvira Espindola", "Elvira Espindola", "Via del Corso, 22", "30003", false);
            Student p1 = new Student("Sergey Afonso");
            Student p2 = new Student("Nadia Teixeira");
            Student p3 = new Student("Elvira Espindola");

            lb.ModifyUser(p1.PersonID, p1.Name, p1.Adress, p1.PhoneNumber, p1.UserType + 1);

            Debug.Assert(SDM.LMS.GetDoc(b1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b2.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(b3.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(av1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(av2.ID) != null);

            Debug.Assert(b1.Quantity == 3);
            Debug.Assert(b2.Quantity == 2);
            Debug.Assert(b3.Quantity == 1);
            Debug.Assert(av1.Quantity == 1);
            Debug.Assert(av2.Quantity == 1);

            Debug.Assert(SDM.LMS.GetUser(p1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p3.PersonID) != null);
        }
Beispiel #10
0
        public void Initial()
        {
            SDM.LMS.ClearDB();

            SDM.LMS.RegisterUser("lb", "lb", "lb", "lb", "lb", true);
            Librarian lb = new Librarian("lb");

            admin.ModifyLibrarian(lb.PersonID, "lb", "lb", "lb", 2);

            lb.AddBook
            (
                "Introduction to Algorithms",
                "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein",
                "MIT Press",
                2009,
                "Third Edition",
                "Alghorithm techniques and design",
                5000,
                false,
                3,
                ""
            );
            lb.AddBook
            (
                "Design Patterns: Elements of Reusable Object-Oriented Software",
                "Erich Gamma, Ralph Johnson, John Vlissides, Richard Helm",
                "Addison-Wesley Professional",
                2003,
                "First Edition",
                "Programm patterns, how to programm well w/o headache",
                1700,
                true,
                3,
                ""
            );
            lb.AddAV("Null References: The Billion Dollar Mistake", "Tony Hoare", 700, 2, "");
            DocClass d1 = new DocClass("Introduction to Algorithms");
            DocClass d2 = new DocClass("Design Patterns: Elements of Reusable Object-Oriented Software");
            DocClass d3 = new DocClass("Null References: The Billion Dollar Mistake");

            lb.RegisterUser("p1", "p1", "p1", "Via Margutta, 3", "30001", false);
            lb.RegisterUser("p2", "p2", "p2", "Via Sacra, 13", "30002", false);
            lb.RegisterUser("p3", "p3", "p3", "Via del Corso, 22", "30003", false);
            lb.RegisterUser("s", "s", "s", "s", "s", false);
            lb.RegisterUser("v", "v", "v", "v", "v", false);
            Student p1 = new Student("p1");
            Student p2 = new Student("p2");
            Student p3 = new Student("p3");
            Student s  = new Student("s");
            Student v  = new Student("v");

            lb.ModifyUser(p1.PersonID, p1.Name, p1.Adress, p1.PhoneNumber, 4);
            lb.ModifyUser(p2.PersonID, p2.Name, p2.Adress, p2.PhoneNumber, 4);
            lb.ModifyUser(p3.PersonID, p3.Name, p3.Adress, p3.PhoneNumber, 4);
            lb.ModifyUser(v.PersonID, v.Name, v.Adress, v.PhoneNumber, 3);

            Debug.Assert(SDM.LMS.GetDoc(d1.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(d2.ID) != null);
            Debug.Assert(SDM.LMS.GetDoc(d3.ID) != null);

            Debug.Assert(d1.Quantity == 3);
            Debug.Assert(d2.Quantity == 3);
            Debug.Assert(d3.Quantity == 2);

            Debug.Assert(SDM.LMS.GetUser(p1.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p2.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(p3.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(s.PersonID) != null);
            Debug.Assert(SDM.LMS.GetUser(v.PersonID) != null);
        }
Beispiel #11
0
 public void ReplaceLibrarian(Librarian previousLibrarian, Librarian currentLibrarian)
 {
     throw new NotImplementedException();
 }
Beispiel #12
0
 public void RemoveLibrarian(Librarian librarian)
 {
     throw new NotImplementedException();
 }
Beispiel #13
0
        //Delete librarian
        public ActionResult Delete(int?id)
        {
            Librarian libs = db.Librarians.Find(id);

            return(View(libs));
        }
Beispiel #14
0
 public LibrarianView(MainForm mainform, Librarian librarian)
 {
     InitializeComponent();
     mainForm       = mainform;
     this.librarian = librarian;
 }
Beispiel #15
0
 public LibrarianTest()
 {
     l1 = new Librarian("Name1", new LibraryDepartment("Абонемент", true));
     l2 = new Librarian("Name2", new LibraryDepartment("Читальный зал", false));
     l3 = new Librarian(l1.Id, l1.FullName, l1.Department);
 }
Beispiel #16
0
 public static void EditLibrarian(Librarian librarian)
 {
     EditUser(librarian);
 }
Beispiel #17
0
 public static void MyClassInitialize(TestContext testContext)
 {
     _librarian = new Librarian(string.Empty);
 }
        public Librarian FindId(int id)
        {
            Librarian librarian = _libraryContext.Librarians.Find(id);

            return(librarian);
        }
 /// <summary>
 /// The signout action result
 /// </summary>
 /// <returns>The index page and the state of the system changes to no one being logged in</returns>
 /// @precondition none
 /// @postcondition the current user is set to null
 public IActionResult Signout()
 {
     CurrentUser      = null;
     CurrentLibrarian = null;
     return(RedirectToAction("Index"));
 }
Beispiel #20
0
        /// <summary>
        /// Main running method for the application.
        /// </summary>
        /// <param name="args">Commandline arguments to the application.</param>
        /// <returns>Returns the application error code.</returns>
        private int Run(string[] args)
        {
            try
            {
                XmlSchemaCollection objectSchema = new XmlSchemaCollection();
                FileInfo            currentFile  = null;

                ArrayList intermediates = new ArrayList();
                Librarian librarian     = null;

                // parse the command line
                this.ParseCommandLine(args);

                // exit if there was an error parsing the command line (otherwise the logo appears after error messages)
                if (this.messageHandler.FoundError)
                {
                    return(this.messageHandler.PostProcess());
                }

                if (0 == this.objectFiles.Count)
                {
                    this.showHelp = true;
                }
                else if (null == this.outputFile)
                {
                    if (1 < this.objectFiles.Count)
                    {
                        throw new ArgumentException("must specify output file when using more than one input file", "-out");
                    }

                    FileInfo fi = (FileInfo)this.objectFiles[0];
                    this.outputFile = new FileInfo(Path.ChangeExtension(fi.Name, ".wix"));                       // we'll let the linker change the extension later
                }

                if (this.showLogo)
                {
                    Assembly litAssembly = Assembly.GetExecutingAssembly();

                    Console.WriteLine("Microsoft (R) Windows Installer Xml Library Tool version {0}", litAssembly.GetName().Version.ToString());
                    Console.WriteLine("Copyright (C) Microsoft Corporation 2003. All rights reserved.");
                    Console.WriteLine();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(" usage:  lit.exe [-?] [-nologo] [-out outputFile] objectFile [objectFile ...]");
                    Console.WriteLine();
                    Console.WriteLine("   -nologo    skip printing lit logo information");
                    Console.WriteLine("   -out       specify output file (default: write to current directory)");
                    Console.WriteLine();
                    Console.WriteLine("   -ext       extension (class, assembly), should extend SchemaExtension or BinderExtension");
                    Console.WriteLine("   -ss        suppress schema validation of documents (performance boost)");
                    Console.WriteLine("   -sv        suppress intermediate file version mismatch checking");
                    Console.WriteLine("   -ust       use small table definitions (for backwards compatiblity)");
                    Console.WriteLine("   -wx        treat warnings as errors");
                    Console.WriteLine("   -w<N>      set the warning level (0: show all, 3: show none)");
                    Console.WriteLine("   -sw        suppress all warnings (same as -w3)");
                    Console.WriteLine("   -sw<N>     suppress warning with specific message ID");
                    Console.WriteLine("   -v         verbose output (same as -v2)");
                    Console.WriteLine("   -v<N>      sets the level of verbose output (0: most output, 3: none)");
                    Console.WriteLine("   -?         this help information");
                    Console.WriteLine();
                    Console.WriteLine("Common extensions:");
                    Console.WriteLine("   .wxs    - Windows installer Xml Source file");
                    Console.WriteLine("   .wxi    - Windows installer Xml Include file");
                    Console.WriteLine("   .wixobj - Windows installer Xml Object file (in XML format)");
                    Console.WriteLine("   .wixlib - Windows installer Xml Library file (in XML format)");
                    Console.WriteLine("   .wixout - Windows installer Xml Output file (in XML format)");
                    Console.WriteLine();
                    Console.WriteLine("   .msm - Windows installer Merge Module");
                    Console.WriteLine("   .msi - Windows installer Product Database");
                    Console.WriteLine("   .mst - Windows installer Transform");
                    Console.WriteLine("   .pcp - Windows installer Patch Creation Package");
                    Console.WriteLine();
                    Console.WriteLine("For more information see: http://wix.sourceforge.net");

                    return(this.messageHandler.PostProcess());
                }

                // create the librarian
                librarian          = new Librarian(this.useSmallTables);
                librarian.Message += new MessageEventHandler(this.messageHandler.Display);

                // load any extensions
                foreach (string extension in this.extensionList)
                {
                    Type extensionType = Type.GetType(extension);
                    if (null == extensionType)
                    {
                        throw new WixInvalidExtensionException(extension);
                    }

                    if (extensionType.IsSubclassOf(typeof(SchemaExtension)))
                    {
                        librarian.AddExtension((SchemaExtension)Activator.CreateInstance(extensionType));
                    }
                }

                // load the object schema
                if (!this.suppressSchema)
                {
                    Assembly wixAssembly = Assembly.Load("wix");

                    using (Stream objectsSchemaStream = wixAssembly.GetManifestResourceStream("Microsoft.Tools.WindowsInstallerXml.Xsd.objects.xsd"))
                    {
                        XmlReader reader = new XmlTextReader(objectsSchemaStream);
                        objectSchema.Add("http://schemas.microsoft.com/wix/2003/04/objects", reader);
                    }
                }

                // add the Intermediates to the librarian
                foreach (FileInfo objectFile in this.objectFiles)
                {
                    currentFile = objectFile;

                    // load the object file into an intermediate object and add it to the list to be linked
                    using (Stream fileStream = new FileStream(currentFile.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        XmlReader fileReader = new XmlTextReader(fileStream);

                        try
                        {
                            XmlReader intermediateReader = fileReader;
                            if (!this.suppressSchema)
                            {
                                intermediateReader = new XmlValidatingReader(fileReader);
                                ((XmlValidatingReader)intermediateReader).Schemas.Add(objectSchema);
                            }

                            Intermediate intermediate = Intermediate.Load(intermediateReader, currentFile.FullName, librarian.TableDefinitions, this.suppressVersionCheck);
                            intermediates.Add(intermediate);
                            continue;                             // next file
                        }
                        catch (WixNotIntermediateException)
                        {
                            // try another format
                        }

                        Library objLibrary = Library.Load(currentFile.FullName, librarian.TableDefinitions, this.suppressVersionCheck);
                        intermediates.AddRange(objLibrary.Intermediates);
                    }

                    currentFile = null;
                }

                // and now for the fun part
                Library library = librarian.Combine((Intermediate[])intermediates.ToArray(typeof(Intermediate)));

                // save the library output if an error did not occur
                if (null != library)
                {
                    library.Save(this.outputFile.FullName);
                }
            }
            catch (WixException we)
            {
                // TODO: once all WixExceptions are converted to errors, this clause
                // should be a no-op that just catches WixFatalErrorException's
                this.messageHandler.Display("lit.exe", "LIT", we);
                return(1);
            }
            catch (Exception e)
            {
                this.OnMessage(WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace));
                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            return(this.messageHandler.PostProcess());
        }
Beispiel #21
0
        public void Add(Librarian entity)
        {
            var response = librarianContext.Add(entity);

            librarianContext.SaveChanges();
        }
Beispiel #22
0
        /// <summary>
        /// Map from cabinet file ids to a normalized relative path.
        /// </summary>
        /// <param name="path">Path to Wixlib.</param>
        /// <returns>Returns the map.</returns>
        private static Dictionary<string, string> GetCabinetFileIdToFileNameMap(string path)
        {
            Dictionary<string, string> mapCabinetFileIdToFileName = new Dictionary<string, string>();
            BlastBinderFileManager binderFileManager = new BlastBinderFileManager(path);
            Librarian librarian = new Librarian();
            Library library = Library.Load(path, librarian.TableDefinitions, false, false);

            foreach (Section section in library.Sections)
            {
                foreach (Table table in section.Tables)
                {
                    foreach (Row row in table.Rows)
                    {
                        foreach (Field field in row.Fields)
                        {
                            ObjectField objectField = field as ObjectField;

                            if (null != objectField && null != objectField.Data)
                            {
                                string filePath = binderFileManager.ResolveFile(objectField.Data as string, "source", row.SourceLineNumbers, BindStage.Normal);
                                mapCabinetFileIdToFileName[objectField.CabinetFileId] = filePath;
                            }
                        }
                    }
                }
            }

            return mapCabinetFileIdToFileName;
        }
Beispiel #23
0
        public void Update(Librarian entity)
        {
            var response = librarianContext.Update(entity);

            librarianContext.SaveChanges();
        }
Beispiel #24
0
        /// <summary>
        /// Main running method for the application.
        /// </summary>
        /// <param name="args">Commandline arguments to the application.</param>
        /// <returns>Returns the application error code.</returns>
        private int Run(string[] args)
        {
            try
            {
                XmlSchemaCollection objectSchema = new XmlSchemaCollection();
                FileInfo currentFile = null;

                ArrayList intermediates = new ArrayList();
                Librarian librarian = null;

                // parse the command line
                this.ParseCommandLine(args);

                // exit if there was an error parsing the command line (otherwise the logo appears after error messages)
                if (this.messageHandler.FoundError)
                {
                    return this.messageHandler.PostProcess();
                }

                if (0 == this.objectFiles.Count)
                {
                    this.showHelp = true;
                }
                else if (null == this.outputFile)
                {
                    if (1 < this.objectFiles.Count)
                    {
                        throw new ArgumentException("must specify output file when using more than one input file", "-out");
                    }

                    FileInfo fi = (FileInfo)this.objectFiles[0];
                    this.outputFile = new FileInfo(Path.ChangeExtension(fi.Name, ".wix"));   // we'll let the linker change the extension later
                }

                if (this.showLogo)
                {
                    Assembly litAssembly = Assembly.GetExecutingAssembly();

                    Console.WriteLine("Microsoft (R) Windows Installer Xml Library Tool version {0}", litAssembly.GetName().Version.ToString());
                    Console.WriteLine("Copyright (C) Microsoft Corporation 2003. All rights reserved.");
                    Console.WriteLine();
                }

                if (this.showHelp)
                {
                    Console.WriteLine(" usage:  lit.exe [-?] [-nologo] [-out outputFile] objectFile [objectFile ...]");
                    Console.WriteLine();
                    Console.WriteLine("   -nologo    skip printing lit logo information");
                    Console.WriteLine("   -out       specify output file (default: write to current directory)");
                    Console.WriteLine();
                    Console.WriteLine("   -ext       extension (class, assembly), should extend SchemaExtension or BinderExtension");
                    Console.WriteLine("   -ss        suppress schema validation of documents (performance boost)");
                    Console.WriteLine("   -sv        suppress intermediate file version mismatch checking");
                    Console.WriteLine("   -ust       use small table definitions (for backwards compatiblity)");
                    Console.WriteLine("   -wx        treat warnings as errors");
                    Console.WriteLine("   -w<N>      set the warning level (0: show all, 3: show none)");
                    Console.WriteLine("   -sw        suppress all warnings (same as -w3)");
                    Console.WriteLine("   -sw<N>     suppress warning with specific message ID");
                    Console.WriteLine("   -v         verbose output (same as -v2)");
                    Console.WriteLine("   -v<N>      sets the level of verbose output (0: most output, 3: none)");
                    Console.WriteLine("   -?         this help information");
                    Console.WriteLine();
                    Console.WriteLine("Common extensions:");
                    Console.WriteLine("   .wxs    - Windows installer Xml Source file");
                    Console.WriteLine("   .wxi    - Windows installer Xml Include file");
                    Console.WriteLine("   .wixobj - Windows installer Xml Object file (in XML format)");
                    Console.WriteLine("   .wixlib - Windows installer Xml Library file (in XML format)");
                    Console.WriteLine("   .wixout - Windows installer Xml Output file (in XML format)");
                    Console.WriteLine();
                    Console.WriteLine("   .msm - Windows installer Merge Module");
                    Console.WriteLine("   .msi - Windows installer Product Database");
                    Console.WriteLine("   .mst - Windows installer Transform");
                    Console.WriteLine("   .pcp - Windows installer Patch Creation Package");
                    Console.WriteLine();
                    Console.WriteLine("For more information see: http://wix.sourceforge.net");

                    return this.messageHandler.PostProcess();
                }

                // create the librarian
                librarian = new Librarian(this.useSmallTables);
                librarian.Message += new MessageEventHandler(this.messageHandler.Display);

                // load any extensions
                foreach (string extension in this.extensionList)
                {
                    Type extensionType = Type.GetType(extension);
                    if (null == extensionType)
                    {
                        throw new WixInvalidExtensionException(extension);
                    }

                    if (extensionType.IsSubclassOf(typeof(SchemaExtension)))
                    {
                        librarian.AddExtension((SchemaExtension)Activator.CreateInstance(extensionType));
                    }
                }

                // load the object schema
                if (!this.suppressSchema)
                {
                    Assembly wixAssembly = Assembly.Load("wix");

                    using (Stream objectsSchemaStream = wixAssembly.GetManifestResourceStream("Microsoft.Tools.WindowsInstallerXml.Xsd.objects.xsd"))
                    {
                        XmlReader reader = new XmlTextReader(objectsSchemaStream);
                        objectSchema.Add("http://schemas.microsoft.com/wix/2003/04/objects", reader);
                    }
                }

                // add the Intermediates to the librarian
                foreach (FileInfo objectFile in this.objectFiles)
                {
                    currentFile = objectFile;

                    // load the object file into an intermediate object and add it to the list to be linked
                    using (Stream fileStream = new FileStream(currentFile.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        XmlReader fileReader = new XmlTextReader(fileStream);

                        try
                        {
                            XmlReader intermediateReader = fileReader;
                            if (!this.suppressSchema)
                            {
                                intermediateReader = new XmlValidatingReader(fileReader);
                                ((XmlValidatingReader)intermediateReader).Schemas.Add(objectSchema);
                            }

                            Intermediate intermediate = Intermediate.Load(intermediateReader, currentFile.FullName, librarian.TableDefinitions, this.suppressVersionCheck);
                            intermediates.Add(intermediate);
                            continue; // next file
                        }
                        catch (WixNotIntermediateException)
                        {
                            // try another format
                        }

                        Library objLibrary = Library.Load(currentFile.FullName, librarian.TableDefinitions, this.suppressVersionCheck);
                        intermediates.AddRange(objLibrary.Intermediates);
                    }

                    currentFile = null;
                }

                // and now for the fun part
                Library library = librarian.Combine((Intermediate[])intermediates.ToArray(typeof(Intermediate)));

                // save the library output if an error did not occur
                if (null != library)
                {
                    library.Save(this.outputFile.FullName);
                }
            }
            catch (WixException we)
            {
                // TODO: once all WixExceptions are converted to errors, this clause
                // should be a no-op that just catches WixFatalErrorException's
                this.messageHandler.Display("lit.exe", "LIT", we);
                return 1;
            }
            catch (Exception e)
            {
                this.OnMessage(WixErrors.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace));
                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            return this.messageHandler.PostProcess();
        }
Beispiel #25
0
 public override void Remove(Librarian item)
 {
     Remove(item.Id);
 }