Ejemplo n.º 1
0
		public static async Task<AsyncServerClient> CreateAsyncServerClient(IAsyncDocumentSession session, ServerRecord server, ServerCredentials serverCredentials = null)
		{
			var documentStore = (DocumentStore)session.Advanced.DocumentStore;
			var replicationInformer = new ReplicationInformer(new DocumentConvention
			{
				FailoverBehavior = FailoverBehavior.FailImmediately
			});

			ICredentials credentials = null;
			if (serverCredentials != null)
			{
				credentials = serverCredentials.GetCredentials();
			}
			else if (server.CredentialsId != null)
			{
				serverCredentials = await session.LoadAsync<ServerCredentials>(server.CredentialsId);
				if (serverCredentials == null)
				{
					server.CredentialsId = null;
				}
				else
				{
					credentials = serverCredentials.GetCredentials();
				}
			}

			return new AsyncServerClient(server.Url, documentStore.Conventions, credentials,
										 documentStore.JsonRequestFactory, null, s => replicationInformer, null, new IDocumentConflictListener[0]);
		}
Ejemplo n.º 2
0
        public static async Task <AsyncServerClient> CreateAsyncServerClient(IAsyncDocumentSession session, ServerRecord server, ServerCredentials serverCredentials = null)
        {
            var documentStore       = (DocumentStore)session.Advanced.DocumentStore;
            var replicationInformer = new ReplicationInformer(new DocumentConvention
            {
                FailoverBehavior = FailoverBehavior.FailImmediately
            });

            ICredentials credentials = null;

            if (serverCredentials != null)
            {
                credentials = serverCredentials.GetCredentials();
            }
            else if (server.CredentialsId != null)
            {
                serverCredentials = await session.LoadAsync <ServerCredentials>(server.CredentialsId);

                if (serverCredentials == null)
                {
                    server.CredentialsId = null;
                }
                else
                {
                    credentials = serverCredentials.GetCredentials();
                }
            }

            return(new AsyncServerClient(server.Url, documentStore.Conventions, credentials,
                                         documentStore.JsonRequestFactory, null, s => replicationInformer, null, new IDocumentConflictListener[0]));
        }