コード例 #1
0
        /// <summary>   Specialised constructor for use only by derived class. </summary>
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are
        ///                                             null. </exception>
        /// <param name="applicationFolder">    Pathname of the application folder. </param>
        /// <param name="dbFolderName">         (Optional) Pathname of the database folder. </param>
        protected DbreezeDataService(string applicationFolder, string dbFolderName = "dbreeze")
        {
            if (string.IsNullOrWhiteSpace(dbFolderName))
            {
                throw new ArgumentNullException(nameof(dbFolderName));
            }
            if (string.IsNullOrWhiteSpace(applicationFolder))
            {
                throw new ArgumentNullException(nameof(applicationFolder));
            }

            // ReSharper disable once VirtualMemberCallInConstructor
            Database    = new DBreezeEngine(ConstructAppDataDbFileName(applicationFolder, dbFolderName));
            NameService = new EntityNameAttributeNameService();
        }
コード例 #2
0
        /// <summary>	Specialised constructor for use only by derived class. </summary>
        /// <remarks>
        ///     If dbFilePath isnt rooted or doesnt start with a dot - an applicationFolder is required,
        ///     because the service will save in local-appdata.
        /// </remarks>
        /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
        /// <exception cref="ArgumentException">
        ///     Thrown when one or more arguments have unsupported or
        ///     illegal values.
        /// </exception>
        /// <param name="useSingletonConnection">	True to use singleton connection. </param>
        /// <param name="dbFilePath">			    Full pathname of the database file. </param>
        /// <param name="applicationFolder">	    (Optional) Pathname of the application folder. </param>
        protected LiteDbDataService(bool?useSingletonConnection, string dbFilePath, string applicationFolder = null)
        {
            if (string.IsNullOrWhiteSpace(dbFilePath))
            {
                throw new ArgumentNullException(nameof(dbFilePath));
            }

            if (!Path.IsPathRooted(dbFilePath) && !dbFilePath.StartsWith("."))
            {
                if (string.IsNullOrWhiteSpace(applicationFolder))
                {
                    throw new ArgumentException(
                              $"Giving non-rooted {nameof(dbFilePath)} requires giving an {nameof(applicationFolder)}.");
                }
            }
            _useSingletonConnection = useSingletonConnection ?? false;

            Database = _useSingletonConnection
                ? LiteDbDatabaseSingleton.GetDatabase(dbFilePath)
                : new LiteDatabase(dbFilePath);
            NameService = new EntityNameAttributeNameService();
        }
コード例 #3
0
 public virtual void Initialize()
 {
     NameService = new EntityNameAttributeNameService();
 }