Exemplo n.º 1
0
        public HeaderViewModel(
            IMonitorStreamsModel monitorStreamsModel,
            StreamLauncher streamLauncher,
            FilterModel filterModelModel,
            IApiClientFactory apiClientFactory,
            ApiClientsQualitiesViewModel apiClientsQualitiesViewModel,
            IWindowManager windowManager)
        {
            if (monitorStreamsModel == null)
            {
                throw new ArgumentNullException(nameof(monitorStreamsModel));
            }
            if (streamLauncher == null)
            {
                throw new ArgumentNullException(nameof(streamLauncher));
            }
            if (filterModelModel == null)
            {
                throw new ArgumentNullException(nameof(filterModelModel));
            }
            if (apiClientFactory == null)
            {
                throw new ArgumentNullException(nameof(apiClientFactory));
            }

            FilterModel                       = filterModelModel;
            MonitorStreamsModel               = monitorStreamsModel;
            this.streamLauncher               = streamLauncher;
            this.apiClientFactory             = apiClientFactory;
            this.windowManager                = windowManager;
            this.apiClientsQualitiesViewModel = apiClientsQualitiesViewModel ?? throw new ArgumentNullException(nameof(apiClientsQualitiesViewModel));
        }
Exemplo n.º 2
0
    static PullRequestService CreateTarget(
        IGitClient gitClient                 = null,
        IGitService gitService               = null,
        IVSGitExt gitExt                     = null,
        IApiClientFactory apiClientFactory   = null,
        IGraphQLClientFactory graphqlFactory = null,
        IOperatingSystem os                  = null,
        IUsageTracker usageTracker           = null)
    {
        gitClient        = gitClient ?? Substitute.For <IGitClient>();
        gitService       = gitService ?? Substitute.For <IGitService>();
        gitExt           = gitExt ?? Substitute.For <IVSGitExt>();
        apiClientFactory = apiClientFactory ?? Substitute.For <IApiClientFactory>();
        graphqlFactory   = graphqlFactory ?? Substitute.For <IGraphQLClientFactory>();
        os           = os ?? Substitute.For <IOperatingSystem>();
        usageTracker = usageTracker ?? Substitute.For <IUsageTracker>();

        return(new PullRequestService(
                   gitClient,
                   gitService,
                   gitExt,
                   apiClientFactory,
                   graphqlFactory,
                   os,
                   usageTracker));
    }
 public ApiClientsQualitiesViewModel(
     ISettingsHandler settingsHandler,
     IApiClientFactory apiClientFactory)
 {
     this.apiClientFactory = apiClientFactory ?? throw new ArgumentNullException(nameof(apiClientFactory));
     this.settingsHandler  = settingsHandler ?? throw new ArgumentNullException(nameof(settingsHandler));
 }
Exemplo n.º 4
0
 public MonitoredStreamsFileHandler(
     IApiClientFactory apiClientFactory,
     ITwitchTvHelixReadonlyClient twitchTvHelixReadonlyClient)
 {
     this.apiClientFactory            = apiClientFactory ?? throw new ArgumentNullException(nameof(apiClientFactory));
     this.twitchTvHelixReadonlyClient = twitchTvHelixReadonlyClient ?? throw new ArgumentNullException(nameof(twitchTvHelixReadonlyClient));
 }
Exemplo n.º 5
0
        public HeaderViewModel(
            IMonitorStreamsModel monitorStreamsModel,
            StreamLauncher streamLauncher,
            FilterModel filterModelModel,
            IApiClientFactory apiClientFactory)
        {
            if (monitorStreamsModel == null)
            {
                throw new ArgumentNullException(nameof(monitorStreamsModel));
            }
            if (streamLauncher == null)
            {
                throw new ArgumentNullException(nameof(streamLauncher));
            }
            if (filterModelModel == null)
            {
                throw new ArgumentNullException(nameof(filterModelModel));
            }
            if (apiClientFactory == null)
            {
                throw new ArgumentNullException(nameof(apiClientFactory));
            }

            FilterModel           = filterModelModel;
            MonitorStreamsModel   = monitorStreamsModel;
            this.streamLauncher   = streamLauncher;
            this.apiClientFactory = apiClientFactory;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IssueishService"/> class.
 /// </summary>
 /// <param name="apiClientFactory">The API client factory.</param>
 /// <param name="graphqlFactory">The GraphQL client factory.</param>
 public IssueishService(
     IApiClientFactory apiClientFactory,
     IGraphQLClientFactory graphqlFactory)
 {
     this.apiClientFactory = apiClientFactory;
     this.graphqlFactory   = graphqlFactory;
 }
Exemplo n.º 7
0
 public ShowPullRequestCommentsCommand(
     IApiClientFactory apiClientFactory,
     IPullRequestSessionManager sessionManager)
     : base(CommandSet, CommandId)
 {
     this.apiClientFactory = apiClientFactory;
     this.sessionManager   = sessionManager;
 }
Exemplo n.º 8
0
 public DocumentParsing(IApiClientFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     client = factory.GetClient();
 }
 public MonitoredStreamsFileHandler(IApiClientFactory apiClientFactory)
 {
     if (apiClientFactory == null)
     {
         throw new ArgumentNullException(nameof(apiClientFactory));
     }
     this.apiClientFactory = apiClientFactory;
 }
Exemplo n.º 10
0
 public void SetupBeforeEachTest()
 {
     this.neoApi = A.Fake <ISendRestCommandsToNeo>();
     A.CallTo(() => this.neoApi.SendCommandAsync(A <string> ._)).Returns(JsonConvert.DeserializeObject <NeoResponse>(Response));
     this.apiClientFactory = A.Fake <IApiClientFactory>();
     A.CallTo(() => this.apiClientFactory.GetApiClient()).Returns(this.neoApi);
     this.neoClient = new NeoClient(this.apiClientFactory);
 }
Exemplo n.º 11
0
 public static Task <Count> GetCountOfRecords(IApiClientFactory factory, Settings settings, Endpoint?endpoint)
 {
     return(endpoint != null
         ? endpoint.GetCountOfRecords(factory, settings)
         : Task.FromResult(new Count {
         Kind = Count.Types.Kind.Unavailable
     }));
 }
 public AnomalyAnalysis(IApiClientFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     client = factory.GetClient();
 }
Exemplo n.º 13
0
 public Plugin(HttpClient client = null)
 {
     _apiClientFactory = new ApiClientFactory(client ?? new HttpClient());
     _server           = new ServerStatus
     {
         Connected       = false,
         WriteConfigured = false
     };
 }
 public InlineCommentPeekService(
     IApiClientFactory apiClientFactory,
     IOutliningManagerService outliningManager,
     IPeekBroker peekBroker)
 {
     this.apiClientFactory = apiClientFactory;
     this.outliningService = outliningManager;
     this.peekBroker       = peekBroker;
 }
Exemplo n.º 15
0
 public ModelServiceFactory(
     IApiClientFactory apiClientFactory,
     IHostCacheFactory hostCacheFactory,
     IAvatarProvider avatarProvider)
 {
     this.apiClientFactory = apiClientFactory;
     this.hostCacheFactory = hostCacheFactory;
     this.avatarProvider   = avatarProvider;
 }
Exemplo n.º 16
0
 public MonitorStreamsModel(
     IMonitoredStreamsFileHandler fileHandler,
     ISettingsHandler settingsHandler,
     IApiClientFactory apiClientFactory)
 {
     this.fileHandler      = fileHandler ?? throw new ArgumentNullException(nameof(fileHandler));
     this.settingsHandler  = settingsHandler ?? throw new ArgumentNullException(nameof(settingsHandler));
     this.apiClientFactory = apiClientFactory ?? throw new ArgumentNullException(nameof(apiClientFactory));
 }
Exemplo n.º 17
0
        public AgentStatusService(IApiClientFactory apiClientFactory, IConfigurationService configurationService,
                                  ILogger logger)
        {
            _registrationQueueApiClient = apiClientFactory.GetClientFor <AgentRegistrationQueue>();
            _agentApiClient             = apiClientFactory.GetClientFor <Models.Resources.V1.Agent>();

            _agentConfiguration = configurationService.Get <AgentConfiguration>();
            _logger             = logger;
        }
Exemplo n.º 18
0
 public SentimentTracking(IApiClientFactory factory)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     client = factory.GetClient();
     client = client ?? throw new ArgumentNullException(nameof(client));
 }
Exemplo n.º 19
0
        private static async Task <Schema> GetSchemaForEndpoint(IApiClientFactory factory, Settings settings, Schema schema, Endpoint?endpoint)
        {
            if (endpoint == null)
            {
                return(schema);
            }

            if (endpoint.ShouldGetStaticSchema)
            {
                return(await endpoint.GetStaticSchemaAsync(factory, settings, schema));
            }

            var recordsListRaw = await endpoint.ReadRecordsAsync(factory, settings, null, null, true).Take(100).ToListAsync();

            var recordsList = recordsListRaw
                              .Select(r => JsonConvert.DeserializeObject <Dictionary <string, object> >(r.DataJson))
                              .ToList();

            var types = GetPropertyTypesFromRecords(recordsList);

            var record = recordsList.FirstOrDefault();

            var properties = new List <Property>();

            if (record != null)
            {
                foreach (var recordKey in record.Keys)
                {
                    var property = new Property
                    {
                        Id              = recordKey,
                        Name            = recordKey,
                        Type            = types[recordKey],
                        IsKey           = endpoint.PropertyKeys.Contains(recordKey),
                        IsCreateCounter = false,
                        IsUpdateCounter = false,
                        TypeAtSource    = await endpoint.IsCustomProperty(factory, settings, recordKey)
                            ? Constants.CustomProperty
                            : "",
                        IsNullable = true
                    };

                    properties.Add(property);
                }
            }

            schema.Properties.Clear();
            schema.Properties.AddRange(properties);

            if (schema.Properties.Count == 0)
            {
                schema.Description = Constants.EmptySchemaDescription;
            }

            return(schema);
        }
Exemplo n.º 20
0
        public SearchService(IApiClientFactory apiClientFactory, IConfiguration configuration, ILogger <SearchService> logger)
        {
            _searchEngines    = new List <SearchEngineConfiguration>();
            _apiClientFactory = apiClientFactory;
            _logger           = logger;

            var section = configuration.GetSection("SearchEngines");

            section.Bind(_searchEngines);
        }
        public VodListViewModel(
            StreamLauncher streamLauncher,
            IMonitorStreamsModel monitorStreamsModel,
            IApiClientFactory apiClientFactory)
        {
            this.streamLauncher = streamLauncher ?? throw new ArgumentNullException(nameof(streamLauncher));
            this.monitorStreamsModel = monitorStreamsModel ?? throw new ArgumentNullException(nameof(monitorStreamsModel));
            this.apiClientFactory = apiClientFactory ?? throw new ArgumentNullException(nameof(apiClientFactory));

            ItemsPerPage = VOD_TILES_PER_PAGE;
        }
Exemplo n.º 22
0
 public ModelServiceFactory(
     IApiClientFactory apiClientFactory,
     IHostCacheFactory hostCacheFactory,
     IAvatarProvider avatarProvider,
     [Import(AllowDefault = true)] JoinableTaskContext joinableTaskContext)
 {
     this.apiClientFactory = apiClientFactory;
     this.hostCacheFactory = hostCacheFactory;
     this.avatarProvider   = avatarProvider;
     JoinableTaskContext   = joinableTaskContext ?? ThreadHelper.JoinableTaskContext;
 }
Exemplo n.º 23
0
        public virtual async Task <Count> GetCountOfRecords(IApiClientFactory factory, Settings settings)
        {
            var response = await factory.CreateApiClient(settings).GetAsync($"{BasePath.TrimEnd('/')}/{AllPath.TrimStart('/')}");

            var recordsList = JsonConvert.DeserializeObject <DataWrapper>(await response.Content.ReadAsStringAsync());

            return(new Count
            {
                Kind = Count.Types.Kind.Exact,
                Value = (int)recordsList.TotalRecords
            });
        }
        public PopularLivestreamWatcher(
            ISettingsHandler settingsHandler,
            INotificationHandler notificationHandler,
            INavigationService navigationService,
            IApiClientFactory apiClientFactory)
        {
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }

            this.settingsHandler     = settingsHandler ?? throw new ArgumentNullException(nameof(settingsHandler));
            this.notificationHandler = notificationHandler ?? throw new ArgumentNullException(nameof(notificationHandler));
            this.apiClientFactory    = apiClientFactory ?? throw new ArgumentNullException(nameof(apiClientFactory));

            clickAction = (model, notification) =>
            {
                var livestream = model.Livestreams.FirstOrDefault(x => Equals(x, notification.LivestreamModel));
                if (livestream != null)
                {
                    model.SelectedLivestream = livestream;
                }
                else
                {
                    navigationService.NavigateTo <TopStreamsViewModel>(viewModel => viewModel.SelectedApiClient = notification.LivestreamModel.ApiClient);
                }
            };

            settingsHandler.Settings.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(Settings.MinimumEventViewers))
                {
                    MinimumEventViewers = settingsHandler.Settings.MinimumEventViewers;

                    if (MinimumEventViewers == 0)
                    {
                        watching = false;
                    }
                    else if (stoppedWatching)
                    {
                        StartWatching();
                    }
                }
                else if (args.PropertyName == nameof(Settings.DisableNotifications))
                {
                    if (!settingsHandler.Settings.DisableNotifications)
                    {
                        // clear the existing cache so the next poll can re-add notifications
                        notifiedEvents.ToList().ForEach(x => notifiedEvents.Remove(x.Key));
                    }
                }
            };
        }
 public InlineCommentPeekableItemSourceProvider(
     IApiClientFactory apiClientFactory,
     IInlineCommentPeekService peekService,
     IPullRequestSessionManager sessionManager,
     INextInlineCommentCommand nextCommentCommand,
     IPreviousInlineCommentCommand previousCommentCommand)
 {
     this.apiClientFactory       = apiClientFactory;
     this.peekService            = peekService;
     this.sessionManager         = sessionManager;
     this.nextCommentCommand     = nextCommentCommand;
     this.previousCommentCommand = previousCommentCommand;
 }
Exemplo n.º 26
0
        public void Setup()
        {
            var mockApiUrl = new Uri("http://test.test.com");
            var mockHttp   = new MockHttpMessageHandler();

            mockHttp
            .When(mockApiUrl.ToString())
            .Respond("application/json", _samplie_json);

            _apiClientFactory = MockHelper.CreateClient(mockHttp);

            _service = new CoffeeShopService(_apiClientFactory);
        }
Exemplo n.º 27
0
        public static async IAsyncEnumerable <Schema> GetRefreshSchemas(IApiClientFactory factory, Settings settings,
                                                                        RepeatedField <Schema> refreshSchemas, int sampleSize = 5)
        {
            foreach (var schema in refreshSchemas)
            {
                var endpoint = EndpointHelper.GetEndpointForSchema(schema);

                var refreshSchema = await GetSchemaForEndpoint(factory, settings, schema, endpoint);

                // get sample and count
                yield return(await AddSampleAndCount(factory, settings, refreshSchema, sampleSize, endpoint));
            }
        }
 public RepositoryHostFactory(
     IApiClientFactory apiClientFactory,
     IHostCacheFactory hostCacheFactory,
     ILoginCache loginCache,
     IAvatarProvider avatarProvider,
     ITwoFactorChallengeHandler twoFactorChallengeHandler)
 {
     this.apiClientFactory = apiClientFactory;
     this.hostCacheFactory = hostCacheFactory;
     this.loginCache = loginCache;
     this.avatarProvider = avatarProvider;
     this.twoFactorChallengeHandler = twoFactorChallengeHandler;
 }
Exemplo n.º 29
0
 public RepositoryHostFactory(
     IApiClientFactory apiClientFactory,
     IHostCacheFactory hostCacheFactory,
     ILoginCache loginCache,
     IAvatarProvider avatarProvider,
     ITwoFactorChallengeHandler twoFactorChallengeHandler)
 {
     this.apiClientFactory          = apiClientFactory;
     this.hostCacheFactory          = hostCacheFactory;
     this.loginCache                = loginCache;
     this.avatarProvider            = avatarProvider;
     this.twoFactorChallengeHandler = twoFactorChallengeHandler;
 }
Exemplo n.º 30
0
        public static async IAsyncEnumerable <Record> ReadRecordsAsync(IApiClientFactory factory, Settings settings, Schema schema, DateTime?lastReadTime = null, TaskCompletionSource <DateTime>?tcs = null)
        {
            var endpoint = EndpointHelper.GetEndpointForSchema(schema);

            var records = endpoint?.ReadRecordsAsync(factory, settings, lastReadTime, tcs);

            if (records != null)
            {
                await foreach (var record in records)
                {
                    yield return(record);
                }
            }
        }
Exemplo n.º 31
0
        public ConnectionManager(
            IVSGitServices vsGitServices,
            IConnectionCache cache,
            ILoginManager loginManager,
            IApiClientFactory apiClientFactory)
        {
            this.vsGitServices    = vsGitServices;
            this.cache            = cache;
            this.loginManager     = loginManager;
            this.apiClientFactory = apiClientFactory;

            Connections = new ObservableCollection <IConnection>();
            LoadConnectionsFromCache().Forget();
        }