예제 #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);
            }
        }
예제 #2
0
        internal static IMergeRequestListLoader CreateMergeRequestListLoader(string hostname,
                                                                             DataCacheOperator op, DataCacheConnectionContext context, InternalCacheUpdater cache)
        {
            IVersionLoader versionLoader = new VersionLoader(op, cache);

            IMergeRequestListLoader listLoader = null;

            if (context.CustomData is ProjectBasedContext)
            {
                listLoader = new ProjectBasedMergeRequestLoader(
                    op, versionLoader, cache, context);
            }
            else if (context.CustomData is SearchBasedContext)
            {
                listLoader = new SearchBasedMergeRequestLoader(hostname,
                                                               op, versionLoader, cache, context);
            }
            return(listLoader);
        }