示例#1
0
        async public Task Connect(GitLabInstance gitLabInstance, DataCacheConnectionContext context)
        {
            reset();

            string          hostname       = gitLabInstance.HostName;
            IHostProperties hostProperties = gitLabInstance.HostProperties;

            _operator = new DataCacheOperator(hostname, hostProperties);

            try
            {
                InternalCacheUpdater    cacheUpdater           = new InternalCacheUpdater(new InternalCache());
                IMergeRequestListLoader mergeRequestListLoader =
                    MergeRequestListLoaderFactory.CreateMergeRequestListLoader(hostname, _operator, context, cacheUpdater);

                Trace.TraceInformation(String.Format("[DataCache] Starting new dataCache at {0}", hostname));

                User currentUser = await new CurrentUserLoader(_operator).Load(hostname);
                await mergeRequestListLoader.Load();

                _internal = createCacheInternal(cacheUpdater, hostname, hostProperties, currentUser, context);

                Trace.TraceInformation(String.Format("[DataCache] Started new dataCache at {0}", hostname));
                Connected?.Invoke(hostname, currentUser);
            }
            catch (BaseLoaderException ex)
            {
                if (ex is BaseLoaderCancelledException)
                {
                    throw new DataCacheConnectionCancelledException();
                }
                throw new DataCacheException(ex.OriginalMessage, ex);
            }
        }
 public RawDataAccessor(GitLabInstance gitLabInstance)
 {
     _hostname                       = gitLabInstance.HostName;
     _hostProperties                 = gitLabInstance.HostProperties;
     _modificationListener           = gitLabInstance.ModificationListener;
     _networkOperationStatusListener = gitLabInstance.NetworkOperationStatusListener;
 }
示例#3
0
        async public Task Connect(GitLabInstance gitLabInstance, DataCacheConnectionContext connectionContext)
        {
            assertNotConnected();

            string          hostname       = gitLabInstance.HostName;
            IHostProperties hostProperties = gitLabInstance.HostProperties;

            _operator = new DataCacheOperator(hostname, hostProperties, gitLabInstance.NetworkOperationStatusListener);
            DataCacheOperator myOperator = _operator;

            _isConnecting = true;
            try
            {
                Connecting?.Invoke(hostname);

                InternalCacheUpdater cacheUpdater = new InternalCacheUpdater(new InternalCache());
                bool isApprovalStatusSupported    = await gitLabInstance.IsApprovalStatusSupported();

                IMergeRequestListLoader mergeRequestListLoader = new MergeRequestListLoader(
                    hostname, _operator, cacheUpdater,
                    _cacheContext.Callbacks, connectionContext.QueryCollection,
                    isApprovalStatusSupported);

                traceInformation(String.Format("Connecting data cache to {0}...", hostname));
                string accessToken = hostProperties.GetAccessToken(hostname);
                await new CurrentUserLoader(_operator).Load(hostname, accessToken);
                User currentUser = GlobalCache.GetAuthenticatedUser(hostname, accessToken);

                await mergeRequestListLoader.Load();

                _internal = createCacheInternal(cacheUpdater, hostname, hostProperties, currentUser,
                                                connectionContext.QueryCollection, gitLabInstance.ModificationNotifier,
                                                gitLabInstance.NetworkOperationStatusListener, isApprovalStatusSupported);

                ConnectionContext = connectionContext;
                traceInformation(String.Format("Data cache connected to {0}", hostname));
                Connected?.Invoke(hostname, currentUser);
            }
            catch (BaseLoaderException ex)
            {
                reset();

                if (ex is BaseLoaderCancelledException)
                {
                    throw new DataCacheConnectionCancelledException();
                }
                throw new DataCacheException(ex.OriginalMessage, ex);
            }
            finally
            {
                _isConnecting = false;
            }
        }
示例#4
0
 public RawDataAccessor(GitLabInstance gitLabInstance)
 {
     _hostname       = gitLabInstance.HostName;
     _hostProperties = gitLabInstance.HostProperties;
 }