示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerClient"/> class.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <param name="convention">The convention.</param>
 /// <param name="credentials">The credentials.</param>
 /// <param name="replicationInformer">The replication informer.</param>
 public ServerClient(string url, DocumentConvention convention, ICredentials credentials, ReplicationInformer replicationInformer)
 {
     this.credentials         = credentials;
     this.replicationInformer = replicationInformer;
     this.url          = url;
     this.convention   = convention;
     OperationsHeaders = new NameValueCollection();
     replicationInformer.UpdateReplicationInformationIfNeeded(this);
 }
示例#2
0
        /// <summary>
        /// Initialize the document store access method to RavenDB
        /// </summary>
	    protected virtual void InitializeInternal()
	    {
	        var replicationInformer = new ReplicationInformer();
	        databaseCommandsGenerator = () => new ServerClient(Url, Conventions, credentials, replicationInformer);
	        asyncDatabaseCommandsGenerator = () => new AsyncServerClient(Url, Conventions, credentials);
	    }
示例#3
0
		/// <summary>
		/// Initializes this instance.
		/// </summary>
		/// <returns></returns>
		public IDocumentStore Initialize()
		{
			try
			{
#if !CLIENT
				if (configuration != null)
				{
					DocumentDatabase = new Raven.Database.DocumentDatabase(configuration);
					DocumentDatabase.SpinBackgroundWorkers();
					databaseCommandsGenerator = () => new EmbededDatabaseCommands(DocumentDatabase, Conventions);
				}
				else
#endif
				{
					var replicationInformer = new ReplicationInformer();
					databaseCommandsGenerator = ()=>new ServerClient(Url, Conventions, credentials, replicationInformer);
					asyncDatabaseCommandsGenerator = ()=>new AsyncServerClient(Url, Conventions, credentials);
				}
                if(Conventions.DocumentKeyGenerator == null)// don't overwrite what the user is doing
                {
                    var generator = new MultiTypeHiLoKeyGenerator(this, 1024);
                    Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(Conventions, entity);
                }
			}
			catch (Exception)
			{
				Dispose();
				throw;
			}

            return this;
		}