示例#1
0
        /// <summary>
        /// Connects the client to the remote server.
        /// </summary>
        /// <param name="configuration">The client configuration.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="configuration"/> is null.</exception>
        /// <exception cref="AmbienceException">Thrown if the operation failed.</exception>
        public static AmbienceClient Connect(AmbienceClientConfiguration configuration)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");

            try
            {
                IConfiguration db4oConfig = Db4oFactory.NewConfiguration();
                IObjectContainer db4oContainer = Db4oFactory.OpenClient(db4oConfig,
                    configuration.HostName, configuration.Port,
                    configuration.Credential.UserName, configuration.Credential.Password);
                return new AmbienceClient(new Db4oAmbientDataContainer(db4oContainer));
            }
            catch (Db4oException ex)
            {
                throw new AmbienceException("An error occurred while connecting to the server.", ex);
            }
        }
示例#2
0
        /// <summary>
        /// Connects the client to the remote server.
        /// </summary>
        /// <param name="configuration">The client configuration.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="configuration"/> is null.</exception>
        /// <exception cref="AmbienceException">Thrown if the operation failed.</exception>
        public static AmbienceClient Connect(AmbienceClientConfiguration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            try
            {
                IConfiguration   db4oConfig    = Db4oFactory.NewConfiguration();
                IObjectContainer db4oContainer = Db4oFactory.OpenClient(db4oConfig,
                                                                        configuration.HostName, configuration.Port,
                                                                        configuration.Credential.UserName, configuration.Credential.Password);
                return(new AmbienceClient(new Db4oAmbientDataContainer(db4oContainer)));
            }
            catch (Db4oException ex)
            {
                throw new AmbienceException("An error occurred while connecting to the server.", ex);
            }
        }