Esempio n. 1
0
        public static LibraryCollection GetLibraries(IYZDbProvider provider, IDbConnection cn, string libType, string filter, string sort)
        {
            try
            {
                LibraryCollection alllibs = new LibraryCollection();
                using (YZReader reader = new YZReader(provider.GetLibraries(cn, libType, filter, sort)))
                {
                    while (reader.Read())
                    {
                        Library lib = new Library(reader);

                        if (!String.IsNullOrEmpty(lib.Name))
                        {
                            alllibs.Add(lib);
                        }
                    }
                }

                return(alllibs);
            }
            catch (Exception e)
            {
                throw new BPMException(BPMExceptionType.DBLoadDataErr, "YZAppLibrary", e.Message);
            }
        }
Esempio n. 2
0
        public void Library_AddBook_Correct()
        {
            // Arrange
            List <Book> books = new List <Book>()
            {
                new Book()
                {
                    Id = 1, Name = "Book0"
                },
                new Book()
                {
                    Id = 2, Name = "Book1"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetBooks()).Returns(books);

            ILibrary library = new LibraryCollection(data.Object);
            Book     newBook = new Book()
            {
                Id = 12, Name = "Book12"
            };

            // Act
            library.AddBook(newBook);
            books.Add(newBook);

            // Assert
            Assert.Equal(books, library.GetBooks());
        }
Esempio n. 3
0
        public void Library_GetBookByIndex_Correct()
        {
            // Arrange
            List <Book> books = new List <Book>()
            {
                new Book()
                {
                    Id = 1, Name = "Book0"
                },
                new Book()
                {
                    Id = 2, Name = "Book1"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetBooks()).Returns(books);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            Book book = library.GetBookById(1);

            // Assert
            Assert.Equal(books[0], book);
        }
Esempio n. 4
0
        public void Library_RemoveGenre_Exception(int id)
        {
            // Arrage
            List <Genre> genres = new List <Genre>()
            {
                new Genre()
                {
                    Id = 1, Name = "Genre0"
                },
                new Genre()
                {
                    Id = 2, Name = "Genre1"
                },
                new Genre()
                {
                    Id = 3, Name = "Genre2"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetGenres()).Returns(genres);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                        library.RemoveGenre(id));
        }
Esempio n. 5
0
        public void Library_GetGenreByIndex_Correct()
        {
            // Arrage
            List <Genre> genres = new List <Genre>()
            {
                new Genre()
                {
                    Id = 1, Name = "Genre0"
                },
                new Genre()
                {
                    Id = 2, Name = "Genre1"
                },
                new Genre()
                {
                    Id = 3, Name = "Genre2"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetGenres()).Returns(genres);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            Genre genre = library.GetGenreById(1);

            // Assert
            Assert.Equal(genre, genres[0]);
        }
Esempio n. 6
0
        public void Library_GetAuthorByIndex_Correct()
        {
            // Arrage
            List <Author> authors = new List <Author>()
            {
                new Author()
                {
                    Id = 1, Name = "Name0", Surname = "Surname0"
                },
                new Author()
                {
                    Id = 2, Name = "Name1", Surname = "Surname1"
                },
                new Author()
                {
                    Id = 3, Name = "Name2", Surname = "Surname2"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetAuthors()).Returns(authors);
            ILibrary library = new LibraryCollection(data.Object);

            // Act
            Author author = library.GetAuthorById(1);

            // Assert
            Assert.Equal(author, authors[0]);
        }
Esempio n. 7
0
        public void Library_GetBookByIndex_Exception(int id)
        {
            // Arrange
            List <Book> books = new List <Book>()
            {
                new Book()
                {
                    Id = 1, Name = "Book0"
                },
                new Book()
                {
                    Id = 2, Name = "Book1"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetBooks()).Returns(books);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                        library.GetBookById(id));
        }
Esempio n. 8
0
        public void Library_SetAuthorByIndex_Exception(int id)
        {
            // Arrage
            List <Author> authors = new List <Author>()
            {
                new Author()
                {
                    Id = 1, Name = "Name0", Surname = "Surname0"
                },
                new Author()
                {
                    Id = 2, Name = "Name1", Surname = "Surname1"
                },
                new Author()
                {
                    Id = 3, Name = "Name2", Surname = "Surname2"
                },
            };
            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetAuthors()).Returns(authors);

            ILibrary library   = new LibraryCollection(data.Object);
            Author   newAuthor = new Author();

            // Act
            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(() =>
                                                        library.SetAuthorById(newAuthor, id));
        }
Esempio n. 9
0
 public MainWindow()
 {
     InitializeComponent();
     LibraryCollection   = new LibraryCollection();
     ItemCollection      = new MetadataItemCollection();
     CastCollection      = new ActorCollection();
     AllActorsCollection = new ActorCollection();
 }
Esempio n. 10
0
        public void Library_RemoveAutor_Correct()
        {
            // Arrage
            List <Author> authors = new List <Author>()
            {
                new Author()
                {
                    Id = 0, Name = "Name0", Surname = "Surname0"
                },
                new Author()
                {
                    Id = 1, Name = "Name1", Surname = "Surname1"
                },
                new Author()
                {
                    Id = 2, Name = "Name2", Surname = "Surname2"
                },
            };

            List <BookAuthor> bookAuthors = new List <BookAuthor>()
            {
                new BookAuthor()
                {
                    BookIndex = 0, AuthorIndex = 0
                },
                new BookAuthor()
                {
                    BookIndex = 0, AuthorIndex = 1
                },
                new BookAuthor()
                {
                    BookIndex = 1, AuthorIndex = 2
                },
                new BookAuthor()
                {
                    BookIndex = 1, AuthorIndex = 1
                },
            };
            Mock <IDataProvider> data = new Mock <IDataProvider>();

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetAuthors()).Returns(authors);
            data.Setup(p => p.GetBooksAuthors()).Returns(bookAuthors);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            bookAuthors.RemoveAll(item => item.AuthorIndex == 0);
            authors.RemoveAt(0);
            library.RemoveAuthor(0);

            // Assert
            Assert.Equal(authors, library.GetAuthors());
            Assert.Equal(bookAuthors, library.GetBookAuthors());
        }
Esempio n. 11
0
        /// <summary>
        /// Add a new library to the collection and to persistent storage
        /// </summary>
        /// <param name="newLibrary"></param>
        public static async Task AddLibraryAsync(Library newLibrary)
        {
            LibraryCollection.Add(newLibrary);

            // Need to wait for the Library to be added to ensure that its ID is available
            await DbAccess.InsertAsync(newLibrary);

            // Reform the library names collection
            LibraryNames = LibraryCollection.Select(lib => lib.Name).ToList();
        }
Esempio n. 12
0
        /// <summary>
        /// Get the Library collection from storage
        /// </summary>
        /// <returns></returns>
        public static async Task GetDataAsync()
        {
            if (LibraryCollection == null)
            {
                // Get the current set of libraries
                LibraryCollection = await DbAccess.LoadAsync <Library>();

                LibraryNames = LibraryCollection.Select(lib => lib.Name).ToList();
            }
        }
Esempio n. 13
0
    public static void Main(string[] args)
    {
        Book book1 = new Book("ISBN1", "Title1", new Author("First", "Last"));
        Book book2 = new Book("ISBN2", "Title2", new Author("First", "Last"));
        Book book3 = new Book("ISBN3", "Title3", new Author("First", "Last"));
        Book book4 = new Book("ISBN4", "Title4", new Author("First", "Last"), new DateTime(2011, 02, 21), "John Smith");
        Book book5 = new Book("ISBN5", "Title5", new Author("First", "Last"), new DateTime(1845, 03, 18), "John Appleseed");
        Book book6 = new Book("ISBN6", "Title6", new Author("First", "Last"), new DateTime(2020, 12, 06), "Justin Noble");

        Author author1 = new Author("Gary", "Miles");
        Author author2 = new Author("Abraham", "Lincoln");

        author1.DisplayInfo();
        author2.DisplayInfo();

        author1.AddBook(book1);
        author1.AddBook(book3);
        author1.AddBook(book4);
        author1.DisplayBooks();

        author2.AddBook(book2);
        author2.AddBook(book4);
        author2.AddBook(book6);
        author2.DisplayBooks();

        author1.RemoveBook(book1);
        author1.DisplayBooks();

        Patron patron1 = new Patron("First1", "Last1", "ID1");
        Patron patron2 = new Patron("First2", "Last2", "ID2");
        Patron patron3 = new Patron("First3", "Last3", "ID3");
        Patron patron4 = new Patron("First4", "Last4", "ID4");
        Patron patron5 = new Patron("First5", "Last5", "ID5");

        patron1.AddToRentalCart(book1, new DateTime(2021, 01, 07));

        patron1.AddToRentalCart(book3, DateTime.Today);
        patron1.RemoveFromRentalCart(book3);

        patron1.Display();

        LibraryCollection collection = new LibraryCollection();

        collection.AddPatron(patron1);
        collection.AddPatron(patron2);
        collection.AddPatron(patron3);
        collection.AddPatron(patron4);
        collection.AddPatron(patron5);

        collection.DisplayPatronInfo();

        collection.RemovePatron(patron5);

        collection.DisplayPatronInfo();
    }
Esempio n. 14
0
 private MetroIl2CppVisualStudioSolutionCreator(string installPath, string projectName, string stagingArea, bool installInBuildsFolder, IEnumerable <string> cppPlugins, LibraryCollection libraryCollection)
 {
     this.InstallPath                  = Path.GetFullPath(installPath);
     this.ProjectName                  = projectName;
     this.StagingArea                  = Path.GetFullPath(stagingArea);
     this.InstallInBuildsFolder        = installInBuildsFolder;
     this.CppPlugins                   = cppPlugins;
     this.LibraryCollection            = libraryCollection;
     this.Il2CppOutputProjectDirectory = Path.Combine(this.InstallPath, "Il2CppOutputProject");
     this.UserProjectDirectory         = Path.Combine(this.InstallPath, this.ProjectName);
 }
Esempio n. 15
0
        public void Library_RemoveGenre_NULL()
        {
            // Arrage
            List <Genre> genres = new List <Genre>()
            {
                new Genre()
                {
                    Id = 1, Name = "Genre0"
                },
                new Genre()
                {
                    Id = 2, Name = "Genre1"
                },
                new Genre()
                {
                    Id = 3, Name = "Genre2"
                },
            };
            List <BookGenre> bookGenres = new List <BookGenre>()
            {
                new BookGenre()
                {
                    BookIndex = 1, GenreIndex = 1
                },
                new BookGenre()
                {
                    BookIndex = 1, GenreIndex = 2
                },
                new BookGenre()
                {
                    BookIndex = 2, GenreIndex = 3
                },
                new BookGenre()
                {
                    BookIndex = 2, GenreIndex = 1
                }
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetGenres()).Returns(genres);
            data.Setup(p => p.GetBooksGenres()).Returns(bookGenres);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            Genre actual = library.RemoveGenre(1);

            // Assert
            Assert.Null(actual);
            Assert.Equal(bookGenres, library.GetBookGenres());
        }
Esempio n. 16
0
 internal static void AddPluginPreBuildEvents(TemplateBuilder templateBuilder, LibraryCollection libraryCollection)
 {
     foreach (Library library in libraryCollection)
     {
         string referencePath = library.ReferencePath;
         if (referencePath.StartsWith(@"Plugins\", StringComparison.InvariantCultureIgnoreCase))
         {
             referencePath = "$(ProjectDir)" + referencePath;
             string destinationFile = $"$(ProjectDir){library.Reference}";
             AddPrebuildCopyEvent(templateBuilder, referencePath, destinationFile, library.WinMd && library.Native);
         }
     }
 }
        public ActionResult Index(baseData vData,int? id)
        {
            if (id.HasValue)
                vData.Library = new LibraryEntity(id.Value);

            LibraryCollection lcoll = new LibraryCollection();
            lcoll.GetMulti(null);

            object selObj = vData.Library == null ? null : (object)vData.Library.Id;
            ViewData["databases"] = new SelectList(lcoll, "Id", "Name", selObj);

            return View(vData);
        }
Esempio n. 18
0
        public static void MoveLibraries(IYZDbProvider provider, IDbConnection cn, string libType, int[] libids, int targetlibid, MovePosition position)
        {
            LibraryCollection libs = GetLibraries(provider, cn, libType, null, null);

            libs.Move <int>("LibID", libids, targetlibid, position);

            for (int i = 0; i < libs.Count; i++)
            {
                Library lib = libs[i];
                lib.OrderIndex = i;
                UpdateOrderIndex(provider, cn, lib);
            }
        }
Esempio n. 19
0
        public void Library_UpdateGenre_Correct()
        {
            // Arrange
            List <Book> books = new List <Book>()
            {
                new Book()
                {
                    Id = 1, Name = "Book0"
                },
                new Book()
                {
                    Id = 2, Name = "Book1"
                },
            };
            List <BookGenre> bookGenres = new List <BookGenre>()
            {
                new BookGenre()
                {
                    BookIndex = 1, GenreIndex = 1
                },
                new BookGenre()
                {
                    BookIndex = 1, GenreIndex = 2
                },
                new BookGenre()
                {
                    BookIndex = 2, GenreIndex = 3
                },
                new BookGenre()
                {
                    BookIndex = 2, GenreIndex = 2
                }
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetBooks()).Returns(books);
            data.Setup(p => p.GetBooksGenres()).Returns(bookGenres);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            bookGenres.Add(new BookGenre()
            {
                BookIndex = 0, GenreIndex = 2
            });
            library.UpdateGenre(2, 0);

            // Assert
            Assert.Equal(bookGenres, library.GetBookGenres());
        }
Esempio n. 20
0
        public void Library_SearchByAuthor_Correct()
        {
            // Arrange
            List <Book> books = new List <Book>()
            {
                new Book()
                {
                    Id = 1, Name = "Book0"
                },
                new Book()
                {
                    Id = 2, Name = "Book1"
                },
            };
            List <BookAuthor> bookAuthors = new List <BookAuthor>()
            {
                new BookAuthor()
                {
                    BookIndex = 1, AuthorIndex = 1
                },
                new BookAuthor()
                {
                    BookIndex = 1, AuthorIndex = 2
                },
                new BookAuthor()
                {
                    BookIndex = 2, AuthorIndex = 3
                },
                new BookAuthor()
                {
                    BookIndex = 2, AuthorIndex = 2
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetBooks()).Returns(books);
            data.Setup(p => p.GetBooksAuthors()).Returns(bookAuthors);

            ILibrary library = new LibraryCollection(data.Object);

            // Act
            IEnumerable <Book> expectedBooks = bookAuthors.Where(item => item.AuthorIndex == 0)
                                               .Select(item => books[item.BookIndex]);
            IEnumerable <Book> actualBooks = library.SearchByAuthor(0);

            // Assert
            Assert.Equal(expectedBooks, actualBooks);
        }
Esempio n. 21
0
        public ActionResult Index(baseData vData, int?id)
        {
            if (id.HasValue)
            {
                vData.Library = new LibraryEntity(id.Value);
            }

            LibraryCollection lcoll = new LibraryCollection();

            lcoll.GetMulti(null);

            object selObj = vData.Library == null ? null : (object)vData.Library.Id;

            ViewData["databases"] = new SelectList(lcoll, "Id", "Name", selObj);

            return(View(vData));
        }
        public Library[] GetDocumentLibraries()
        {
            List<Library> libs = new List<Library>();

            LibraryCollection lcoll = new LibraryCollection();
            lcoll.GetMulti(null);

            foreach (LibraryEntity lib in lcoll)
            {
                Library wlib = new Library();
                wlib.Name = lib.Name;
                wlib.Id = lib.Id;
                libs.Add(wlib);
            }

            return libs.ToArray();
        }
Esempio n. 23
0
        public Library[] GetDocumentLibraries()
        {
            List <Library> libs = new List <Library>();

            LibraryCollection lcoll = new LibraryCollection();

            lcoll.GetMulti(null);

            foreach (LibraryEntity lib in lcoll)
            {
                Library wlib = new Library();
                wlib.Name = lib.Name;
                wlib.Id   = lib.Id;
                libs.Add(wlib);
            }

            return(libs.ToArray());
        }
Esempio n. 24
0
        public virtual object GetRootFolders(HttpContext context)
        {
            YZRequest request    = new YZRequest(context);
            int       groupid    = request.GetInt32("groupid", -1);
            string    folderType = request.GetString("folderType");
            string    uid        = YZAuthHelper.LoginUserAccount;

            FileSystem.FolderCollection rootFolders = new FileSystem.FolderCollection();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    string filter = String.Format("FolderType=N'{0}'", provider.EncodeText(folderType));

                    LibraryCollection libs = LibraryManager.GetLibraries(provider, cn, uid, LibraryType.BPAFile.ToString(), null, null);
                    foreach (Library.Library lib in libs)
                    {
                        FileSystem.FolderCollection folders = FileSystem.DirectoryManager.GetFolders(provider, cn, lib.FolderID, filter, null);
                        foreach (FileSystem.Folder folder in folders)
                        {
                            folder.Name = lib.Name;
                        }

                        rootFolders.AddRange(folders);
                    }

                    if (groupid != -1)
                    {
                        Group.Group group = GroupManager.GetGroup(provider, cn, groupid);

                        FileSystem.FolderCollection folders = FileSystem.DirectoryManager.GetFolders(provider, cn, group.FolderID, filter, null);
                        foreach (FileSystem.Folder folder in folders)
                        {
                            folder.Name = group.Name;
                        }

                        rootFolders.AddRange(folders);
                    }
                }
            }

            return(rootFolders);
        }
Esempio n. 25
0
        public static LibraryCollection GetLibraries(IYZDbProvider provider, IDbConnection cn, string uid, string libType, string filter, string sort)
        {
            LibraryCollection alllibs = GetLibraries(provider, cn, libType, filter, sort);

            LibraryCollection libs = new LibraryCollection();

            using (BPMConnection bpmcn = new BPMConnection())
            {
                bpmcn.WebOpen();
                foreach (Library lib in alllibs)
                {
                    string rsid = String.Format("Library://{0}", lib.LibID);
                    if (BPM.Client.Security.SecurityManager.CheckPermision(bpmcn, rsid, BPMPermision.Read))
                    {
                        libs.Add(lib);
                    }
                }
            }
            return(libs);
        }
Esempio n. 26
0
        private void LoadLibraryCollection()
        {
            LibraryCollection.Clear();
            ContainerLibraries.Visibility = Visibility.Visible;
            ItemCollection.Clear();
            ContainerMovies.Visibility = Visibility.Collapsed;
            CastCollection.Clear();
            ContainerCast.Visibility          = Visibility.Collapsed;
            MainGrid.RowDefinitions[2].Height = new GridLength(0);

            lvLibrarySections.ItemsSource = null;

            foreach (DataRow row in Database.GetLibrarySections().Rows)
            {
                LibraryCollection.Add(new Library()
                {
                    id   = long.Parse(row["id"].ToString()),
                    name = row["name"].ToString()
                });
            }

            lvLibrarySections.ItemsSource = LibraryCollection;
        }
Esempio n. 27
0
        public void Library_AddAuthor_Correct()
        {
            // Arrage
            List <Author> authors = new List <Author>()
            {
                new Author()
                {
                    Id = 1, Name = "Name0", Surname = "Surname0"
                },
                new Author()
                {
                    Id = 2, Name = "Name1", Surname = "Surname1"
                },
                new Author()
                {
                    Id = 3, Name = "Name2", Surname = "Surname2"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetAuthors()).Returns(authors);

            ILibrary library   = new LibraryCollection(data.Object);
            Author   newAuthor = new Author()
            {
                Id = 20, Name = "Name10", Surname = "Surname10"
            };

            // Act
            authors.Add(newAuthor);
            library.AddAuthor(newAuthor);

            // Assert
            Assert.Equal(authors, library.GetAuthors());
        }
Esempio n. 28
0
        public virtual object GetRootFolders(HttpContext context)
        {
            YZRequest        request     = new YZRequest(context);
            string           libType     = request.GetString("libType");
            string           uid         = YZAuthHelper.LoginUserAccount;
            FolderCollection rootFolders = new FolderCollection();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    LibraryCollection libs = LibraryManager.GetLibraries(provider, cn, uid, libType, null, null);
                    foreach (Library.Library lib in libs)
                    {
                        Folder folder = DirectoryManager.GetFolderByID(provider, cn, lib.FolderID);
                        folder.Name = lib.Name;

                        rootFolders.Add(folder);
                    }
                }
            }

            return(rootFolders);
        }
Esempio n. 29
0
 public PostProcessWinRT(BuildPostProcessArgs args, WSASDK sdk, string stagingArea = null)
 {
     this._args         = args;
     this._sdk          = sdk;
     this.PlayerPackage = this._args.playerPackage.ConvertToWindowsPath();
     if (stagingArea == null)
     {
     }
     this.StagingArea            = args.stagingArea.ConvertToWindowsPath();
     this.StagingAreaData        = Utility.CombinePath(this.StagingArea, "Data");
     this.StagingAreaDataManaged = Utility.CombinePath(this.StagingAreaData, "Managed");
     this.VisualStudioName       = Utility.GetVsName();
     this.Libraries = new LibraryCollection();
     this.m_ManagedAssemblyLocation = this.StagingAreaDataManaged;
     if (this.SourceBuild)
     {
         string[] paths = new string[] { this.PlayerPackage, "SourceBuild", this.VisualStudioName };
         this.InstallPath = Utility.CombinePath(paths);
     }
     else
     {
         this.InstallPath = args.installPath.ConvertToWindowsPath();
     }
 }
Esempio n. 30
0
        public void Library_AddGenre_Correct()
        {
            // Arrage
            List <Genre> genres = new List <Genre>()
            {
                new Genre()
                {
                    Id = 1, Name = "Genre0"
                },
                new Genre()
                {
                    Id = 2, Name = "Genre1"
                },
                new Genre()
                {
                    Id = 3, Name = "Genre2"
                },
            };

            Mock <IDataProvider> data = new Mock <IDataProvider>();

            data.Setup(p => p.GetGenres()).Returns(genres);

            ILibrary library  = new LibraryCollection(data.Object);
            Genre    newGenre = new Genre()
            {
                Id = 0, Name = "Genre10"
            };

            // Act
            genres.Add(newGenre);
            library.AddGenre(newGenre);

            // Assert
            Assert.Equal(genres, library.GetGenres());
        }
Esempio n. 31
0
    public static void Main(string[] args)
    {
//START PART 1
        //creating book objects
        Book book1 = new Book("11223344", "Legend of Drizzt: Homecoming", "R.A. Salvatore");
        Book book2 = new Book("6958490", "The Lion, The Witch, and The Audacity", "Shel B. Cominround");
        Book book3 = new Book("8675309", "Legend of Drizzt: Wulfgar", "R.A. Salvatore");
        Book book4 = new Book("13121312", "Werner Herzogs Wary Hog", "Shel B. Cominround", Convert.ToDateTime("10/02/1997"), "Walrus Publishing");
        Book book5 = new Book("5415424", "Legend of Drizzt: Cattie-Brie", "R.A. Salvatore", Convert.ToDateTime("12/05/1999"), "Gatehouse Books");
        Book book6 = new Book("9875421", "I Ran Out of Book Titles", "Shel B. Cominround", Convert.ToDateTime("10/4/2015"), "Walrus Publishing");

        //creating author objects
        Author a1 = new Author("R.A.", "Salvatore", "*****@*****.**");
        Author a2 = new Author("Shel B.", "Cominround", "*****@*****.**");

        //Author intros
        a1.DisplayInfo();
        a2.DisplayInfo();

        //book displays - testing purposes only

        /*
         * book1.Display();
         * book2.Display();
         * book3.Display();
         * book4.Display();
         * book5.Display();
         * book6.Display();
         *
         *
         * //Author Book Lists - testing purposes only
         * a1.DisplayBooks();
         * a2.DisplayBooks();
         */

        //Adding books to Authors BookLists & Displaying them
        a1.AddBook(book1);
        a1.AddBook(book3);
        a1.AddBook(book5);
        a1.DisplayBooks();
        a2.AddBook(book2);
        a2.AddBook(book4);
        a2.AddBook(book6);
        a2.DisplayBooks();

        //Removing book1 from a1
        a1.RemoveBook("11223344");

        //Displaying Author 1's Books again
        a1.DisplayBooks();
//END PART 1
//START PART 2
        //Creating Patrons
        Patron p1 = new Patron("Jim", "Jones", "7777");
        Patron p2 = new Patron("Shoko", "Asahara", "8888");
        Patron p3 = new Patron("Brigham", "Young", "9999");
        Patron p4 = new Patron("Ed", "Gein", "1111");
        Patron p5 = new Patron("Marshall", "Applewhite", "2222");

        //Adding Book1 to Patron1's rental cart using AddToRentalCart();
        p1.AddToRentalCart(book1, Convert.ToDateTime("10/2/2021"));

        //Removing Book3 from Patron1's rental cart using RemoveFromRentalCart();
        p1.RemoveFromRentalCart(book3);


        //Displaying Patron Info - Test Purposes only

        /*
         * p1.Display();
         * p2.Display();
         * p3.Display();
         * p4.Display();
         * p5.Display();
         */

//END PART 2
//START PART 3
        LibraryCollection lc1 = new LibraryCollection();

        //I wanted to do something like this:
        //foreach (var Patron in PatronList)
        //{
        // lc1.AddPatron(p);
        //}
        //but I couldnt figure out how to access that list in from main.cs
        lc1.AddPatron(p1);
        lc1.AddPatron(p2);
        lc1.AddPatron(p3);
        lc1.AddPatron(p4);
        lc1.AddPatron(p5);
        lc1.DisplayPatronInfo();
        lc1.RemovePatron(p5);
        lc1.DisplayPatronInfo();
        //same story with adding these books, couldnt figure out how to access it. im sure the answer is really simple.
        lc1.AddToCollection(book1);
        lc1.AddToCollection(book2);
        lc1.AddToCollection(book3);
        lc1.AddToCollection(book4);
        lc1.AddToCollection(book5);
        lc1.AddToCollection(book6);
        lc1.DisplayCollection();
        lc1.RemoveFromCollection(book5);
        lc1.DisplayCollection();

        p1.AddToRentalCart(book1, Convert.ToDateTime("12/12/2012"));
        p1.AddToRentalCart(book2, Convert.ToDateTime("12/13/2012"));
        p1.AddToRentalCart(book3, Convert.ToDateTime("12/14/2012"));
        p1.RemoveFromRentalCart(book3);
        lc1.ProcessRental(p1);
        lc1.DisplayCollection();
        //lc1.ProcessReturns(book2, p1);
        //lc1.DisplayCollection();
        //END PART 3
    }
Esempio n. 32
0
    public static void Main(string[] args)
    {
        Book b1 = new Book("1", "How To Come Up With Names", new Author());
        Book b2 = new Book("2", "My Dog Ate My Computer", new Author());
        Book b3 = new Book("3", "Random Book", new Author());
        Book b4 = new Book("4", "How To Build A Computer", new Author(), DateTime.Parse("5/6/2008"), "Bob Jones Publishing");
        Book b5 = new Book("5", "How To Tie A Knot", new Author(), DateTime.Parse("6/4/2004"), "Publishing Co.");
        Book b6 = new Book("6", "How To Train A Dog", new Author(), DateTime.Parse("3/7/1994"), "Bob Jones Publishing");

        Author bobJones = new Author("Bob", "Jones", "999-99-9999");

        bobJones.Email = "*****@*****.**";
        Author johnDoe = new Author("John", "Doe", "888-88-8888");

        johnDoe.Email = "*****@*****.**";
        bobJones.DisplayInfo();
        johnDoe.DisplayInfo();
        bobJones.AddBook(b1);
        bobJones.AddBook(b3);
        bobJones.AddBook(b5);
        bobJones.DisplayBooks();
        johnDoe.AddBook(b2);
        johnDoe.AddBook(b4);
        johnDoe.AddBook(b6);
        johnDoe.DisplayBooks();
        bobJones.RemoveBook("1");
        bobJones.DisplayBooks();

        /*
         * Part 2
         */
        Patron p1 = new Patron("Alex", "McDonald", "11");
        Patron p2 = new Patron("Robert", "Carpenter", "12");
        Patron p3 = new Patron("James", "Parker", "13");
        Patron p4 = new Patron("Bob", "McDonald", "14");
        Patron p5 = new Patron("Janie", "Wright", "15");

        //p1.AddToRentalCart(b1, DateTime.Today);
        p1.AddToRentalCart(b3, DateTime.Today);
        p1.RemoveFromRentalCart(b3);
        p1.Display();

        /*
         * Part 3
         */
        Console.WriteLine("PART 3");
        LibraryCollection lc = new LibraryCollection();

        lc.AddPatron(p1);
        lc.AddPatron(p2);
        lc.AddPatron(p3);
        lc.AddPatron(p4);
        lc.AddPatron(p5);
        lc.DisplayPatronInfo();
        lc.RemovePatron(p5);
        lc.DisplayPatronInfo();
        lc.AddToCollection(b1);
        lc.AddToCollection(b2);
        lc.AddToCollection(b3);
        lc.AddToCollection(b4);
        lc.AddToCollection(b5);
        lc.AddToCollection(b6);
        lc.DisplayCollection();
        lc.RemoveFromCollection(b5);
        lc.DisplayCollection();
        p1.AddToRentalCart(b1, DateTime.Today); //wasn't specified so I'm using DateTime.Today
        p1.AddToRentalCart(b2, DateTime.Today);
        p1.AddToRentalCart(b3, DateTime.Today);
        p1.RemoveFromRentalCart(b3);
        lc.ProcessRental(p1);
        lc.DisplayCollection();
        lc.ProcessReturns(p1, b2);
        lc.DisplayCollection();
    }
 public static void CreateAssemblyCSharp(CSharpProject project, string playerPackage, string assemblyName, LibraryCollection libraryCollection, WSASDK wsaSDK, CSharpProject[] additionalProjectReferences)
 {
     string relativeFinalProjectDirectory = GetRelativeFinalProjectDirectory(wsaSDK);
     List<AssemblyCSharpPlugin> plugins = new List<AssemblyCSharpPlugin>();
     bool includeUnet = false;
     foreach (Library library in libraryCollection)
     {
         if ((!library.Native || library.WinMd) && (!string.Equals(library.Name, Utility.AssemblyCSharpName, StringComparison.InvariantCultureIgnoreCase) && !string.Equals(library.Name, Utility.AssemblyCSharpFirstPassName, StringComparison.InvariantCultureIgnoreCase)))
         {
             if (string.Equals(library.Name, "UnityEngine.Networking", StringComparison.InvariantCultureIgnoreCase))
             {
                 includeUnet = true;
             }
             string reference = library.Reference;
             string str3 = @"Unprocessed\";
             if (library.WinMd && library.Native)
             {
                 str3 = "";
             }
             if (!reference.StartsWith(@"Plugins\", StringComparison.InvariantCultureIgnoreCase))
             {
                 reference = str3 + library.Reference;
             }
             reference = Utility.CombinePath(relativeFinalProjectDirectory, reference);
             AssemblyCSharpPlugin item = new AssemblyCSharpPlugin {
                 Name = library.Name,
                 HintPath = reference
             };
             plugins.Add(item);
         }
     }
     StringBuilder builder = new StringBuilder();
     string str4 = "$(UnityProjectDir)Assets";
     string[] strArray = new string[] { "Plugins", "Standard Assets", "Standard Assets (Mobile)", "Pro Standard Assets" };
     string additionalReferencePath = "";
     if (additionalProjectReferences != null)
     {
         builder.AppendFormat("    <Compile Include=\"{0}\\**\\*.cs\" Exclude=\"{0}\\**\\Editor\\**\\*.cs", str4);
         foreach (string str6 in strArray)
         {
             builder.AppendFormat(@";{0}\{1}\**\*.cs", str4, str6);
         }
         builder.AppendLine("\">");
         if (str4.StartsWith(".."))
         {
             builder.AppendFormat("      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>", new object[0]);
             builder.AppendLine();
         }
         builder.AppendLine("    </Compile>");
         additionalReferencePath = string.Format("-additionalAssemblyPath=\"{0}\"", MetroVisualStudioSolutionHelper.GetAssemblyCSharpFirstpassDllDir(wsaSDK));
     }
     else
     {
         foreach (string str7 in strArray)
         {
             builder.AppendFormat("    <Compile Include=\"{0}\\{1}\\**\\*.cs\" Exclude=\"{0}\\{1}\\**\\Editor\\**\\*.cs\">", str4, str7);
             builder.AppendLine();
             if (str4.StartsWith(".."))
             {
                 builder.AppendFormat(@"      <Link>{0}\%(RecursiveDir)%(Filename)%(Extension)</Link>", str7);
                 builder.AppendLine();
             }
             builder.AppendLine("    </Compile>");
         }
     }
     if (<>f__am$cache0 == null)
     {