예제 #1
0
        /// <summary>
        /// Constructor to initialize a new object of service.
        /// </summary>
        /// <param name="uri">Base URI for REST service.</param>
        /// <param name="projectName">A project to manage.</param>
        /// <param name="token">A token for user. Can be UID given from user's profile page.</param>
        /// <param name="httpClientFactory">Factory object to create an instance of <see cref="HttpClient"/>.</param>
        public Service(Uri uri, string projectName, string token, IHttpClientFactory httpClientFactory = null)
        {
            ProjectName = projectName;

            if (httpClientFactory == null)
            {
                httpClientFactory = new HttpClientFactory(uri, token);
            }

            _httpClient = httpClientFactory.Create();

            Launch     = new ServiceLaunchResource(_httpClient, ProjectName);
            TestItem   = new ServiceTestItemResource(_httpClient, ProjectName);
            LogItem    = new ServiceLogItemResource(_httpClient, ProjectName);
            User       = new ServiceUserResource(_httpClient, ProjectName);
            UserFilter = new ServiceUserFilterResource(_httpClient, ProjectName);
            Project    = new ServiceProjectResource(_httpClient, ProjectName);
        }
예제 #2
0
        /// <summary>
        /// Constructor to initialize a new object of service.
        /// </summary>
        /// <param name="uri">Base URI for REST service.</param>
        /// <param name="projectName">A project to manage.</param>
        /// <param name="token">A token for user. Can be UID given from user's profile page.</param>
        /// <param name="httpClientFactory">Factory object to create an instance of <see cref="HttpClient"/>.</param>
        public Service(Uri uri, string projectName, string token, IHttpClientFactory httpClientFactory = null)
        {
            ProjectName = projectName;

            if (httpClientFactory == null)
            {
                httpClientFactory = new HttpClientFactory(uri, token);
            }

            _httpClient = httpClientFactory.Create();

#if NET45
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
#endif

            Launch     = new ServiceLaunchResource(_httpClient, ProjectName);
            TestItem   = new ServiceTestItemResource(_httpClient, ProjectName);
            LogItem    = new ServiceLogItemResource(_httpClient, ProjectName);
            User       = new ServiceUserResource(_httpClient, ProjectName);
            UserFilter = new ServiceUserFilterResource(_httpClient, ProjectName);
            Project    = new ServiceProjectResource(_httpClient, ProjectName);
        }