Click here to Skip to main content
15,896,445 members
Articles / Desktop Programming / Windows Forms

BookStore

Rate me:
Please Sign up or sign in to vote.
4.61/5 (25 votes)
24 Apr 2012CPOL5 min read 134.7K   17.8K   98  
A project for managing the digital books (HTML, DOCX, ODF, PDF, EPUB, TXT, etc.) of the user using db4o
using Db4objects.Db4o;
using Db4objects.Db4o.Config;


namespace DataAccess
{

    /// <summary>
    /// Monostate-pattern database configuration class.
    /// </summary>
    static class DBConfiguration
    {

        /// <summary>
        /// db4o-specific configuration interface instance.
        /// </summary>
        private static IConfiguration dbConfig;


        /// <summary>
        /// Static method that sets the db4o configuration.
        /// </summary>
        public static void SetConfiguration()
        {
            dbConfig = Db4oFactory.NewConfiguration();

            dbConfig.BlockSize(BookStoreGUI.Properties.Settings.Default.CurrentBlockSize);
            dbConfig.DatabaseGrowthSize(BookStoreGUI.Properties.Settings.Default.SizeGrowthInBytes);
            dbConfig.LockDatabaseFile(BookStoreGUI.Properties.Settings.Default.LockDatabaseFile);
            dbConfig.OptimizeNativeQueries(BookStoreGUI.Properties.Settings.Default.OptimizeNativeQueries);
            dbConfig.Unicode(BookStoreGUI.Properties.Settings.Default.Unicode);
            dbConfig.ActivationDepth(BookStoreGUI.Properties.Settings.Default.ActivationDepth);
            dbConfig.UpdateDepth(BookStoreGUI.Properties.Settings.Default.UpdateDepth);

            DBSpecificConfiguration.SetConfiguration();
        }


        public static IConfiguration Configuration
        {
            get { return dbConfig; }
        }


        public static void SetIndexedField(object clazz, string indexedField)
        {
            dbConfig.ObjectClass(clazz).ObjectField(indexedField).Indexed(true);
        }

        public static void SetCascadeOnActivate(object clazz)
        {
            dbConfig.ObjectClass(clazz).CascadeOnActivate(true);
        }

        public static void SetCascadeOnDelete(object clazz)
        {
            dbConfig.ObjectClass(clazz).CascadeOnDelete(true);
        }

        public static void SetCascadeOnUpdate(object clazz)
        {
            dbConfig.ObjectClass(clazz).CascadeOnUpdate(true);
        }

    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions