/// <summary> /// Gets the github repo browser internally. Tries to pull the authentication service from memory since that should be a one-time thing. /// The transformation service should be separate in case there are multiple requests from the service and messages in flight. We don't want /// the result array being shared across requests. /// </summary> /// <returns>The github repo browser.</returns> /// <param name="org">Org.</param> /// <param name="config">Config.</param> /// <param name="memoryCache">Memory cache.</param> internal static IRepoBrowser GetGithubRepoBrowser(Organization org, RepoBrowserConfiguration config, IMemoryCache memoryCache) { // Authentication can be re-used string hashKey = ComputeHash(config.AuthType); // First check our cache for the value if (memoryCache != null && memoryCache.TryGetValue(hashKey, out IAuthenticationService authService)) { } else { authService = CreateObjectOfType <IAuthenticationService>(config.AuthType, config.AuthSettings); if (memoryCache != null) { memoryCache.Set(hashKey, authService); } } ITransformationService transformService = CreateObjectOfType <ITransformationService>(config.TransformType); HttpMessageHandler messageHandler = null; if (!string.IsNullOrEmpty(config.HttpMessageHandlerType)) { messageHandler = CreateObjectOfType <HttpMessageHandler>(config.HttpMessageHandlerType); } else { messageHandler = new HttpClientHandler(); } return(new GithubRepoBrowser(authService, transformService, messageHandler)); }
public MainViewModel(ITransformationFileService fileService, ITransformationService transformationService) { this.details = new TransformationDetails(@"C:\ArmTemplate\Output", true); this.ValidationErrors = new ObservableCollection <ValidationError>(); this.transformationFileService = fileService; this.transformationService = transformationService; }
/// <summary> /// Initializes a new instance of the TestWebApi472.Controllers.ConversionController class. /// </summary> /// <param name="derivationService">The derivation service to test.</param> /// <param name="transformationService">The transformation service to test.</param> public ConversionController( IDerivationService <SourceExample, DestExample> derivationService, ITransformationService <SourceExample, DestExample> transformationService ) { DerivationService = derivationService; TransformationService = transformationService; }
public void OneTimeSetUp() { _loggerMock = new Mock <ILogger <TransformationService> >(); _service = new TransformationService(_loggerMock.Object); System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); }
public Bus(IBus bus, ILogger logger, IGenerateKey generateKey, IRuleManager ruleManager, IComponentContext componentContext, ITransformationService transformationService) { _bus = bus; _logger = logger; _generateKey = generateKey; _ruleManager = ruleManager; _componentContext = componentContext; _transformationService = transformationService; }
/// <summary> /// Constructor /// </summary> /// <param name="transformationService"></param> /// <param name="exportService"></param> /// <param name="logger"></param> public ImportExportController(ITransformationService transformationService, IExportService <List <string>, string> exportService, ILogger <ImportExportController> logger) { _transformationService = transformationService ?? throw new ArgumentNullException(nameof(transformationService)); _exportService = exportService ?? throw new ArgumentNullException(nameof(exportService)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); }
public void Setup() { this.reportedError = null; this.userMessage = null; this.inputTemplate = new InputDashboardArmTemplate("SomeJson"); this.completeOutputTemplate = new OutputDashboardArmTemplate("SomeOutputJson", "SomeParametersJson"); this.partOfExistingTemplateOutput = new OutputDashboardArmTemplate("PartOutputJson", "SomeParametersJson"); this.fileService = A.Fake <ITransformationFileService>(); this.transformationService = A.Fake <ITransformationService>(); Messenger.Default.Register <Exception>(this, e => this.reportedError = e); Messenger.Default.Register <string>(this, e => this.userMessage = e); this.mainViewModel = new MainViewModel(this.fileService, this.transformationService); this.mainViewModel.SourceFilePath = @"C:\Input.json"; this.mainViewModel.OutputFolderPath = OutputPath; A.CallTo(() => this.transformationService.Transform(this.inputTemplate, A <TransformationDetails> .That.Matches(x => x.DashboardIsCompleteTemplate.Equals(true)))).Returns(this.completeOutputTemplate); A.CallTo(() => this.transformationService.Transform(this.inputTemplate, A <TransformationDetails> .That.Matches(x => x.DashboardIsCompleteTemplate.Equals(false)))).Returns(this.partOfExistingTemplateOutput); }
public X12TransformationService(ITransformationService preProcessor) { _preProcessor = preProcessor; }
/// <summary> /// Initializes a new instance of the <see cref="TransformationController"/> class. /// </summary> /// <param name="loggerService">The logger service.</param> /// <param name="transformationService">The transformation service.</param> public TransformationController(ILoggerService loggerService, ITransformationService transformationService) : base(loggerService) { this.transformationService = transformationService; }
/// <summary> /// Initializes a new instance of the <see cref="X12HtmlTransformationService"/> class /// </summary> /// <param name="preProcessor">Transformation service preprocessor used prior to transforming</param> public X12HtmlTransformationService(ITransformationService preProcessor) : base(preProcessor) { }
public X12HtmlTransformationService(ITransformationService preProcessor) : base(preProcessor) { _preProcessor = preProcessor; }
public RequestExecutor(ITransformationService transformationService, IBrowser browser) { TransformationService = transformationService; Browser = browser; }
/// <summary> /// Initializes a new instance of the <see cref="X12TransformationService"/> class /// </summary> /// <param name="preProcessor">Transformer preprocessor</param> protected X12TransformationService(ITransformationService preProcessor) { this.PreProcessor = preProcessor; }
public void Get_Init_TransformationService_Without_ILogger_It_Throws() { Assert.Throws <ArgumentNullException>(() => { _service = new TransformationService(null); }); }
public GithubRepoBrowser(IAuthenticationService authService, ITransformationService transformService, HttpMessageHandler httpHandler) { _authService = authService; _transformService = transformService; _httpHandler = httpHandler; }
/// <summary> /// Gets the pull requests. /// </summary> /// <returns>The pull requests.</returns> /// <param name="pullRequest">Pull request request object.</param> /// <param name="repoBrowser">Repo browser.</param> public static async Task <PullRequestResponse> GetPullRequests(PullRequestRequest pullRequest, IRepoBrowser repoBrowser) { IAuthenticationService authService = repoBrowser.GetAuthenticationService(); ITransformationService transformationService = repoBrowser.GetTransformationService(); HttpMessageHandler httpMessageHandler = repoBrowser.GetHttpMessageHandler(); if (authService != null) { try { // First check authentication if (!authService.IsAuthenticated()) { await authService.Authenticate(httpMessageHandler); } } catch (Exception ex) { throw new InvalidOperationException("During authentication, the custom authentication service threw an exception: " + ex.Message); } } // Make the requests and repeat as necessary by the transformation class HttpClient httpClient = new HttpClient(httpMessageHandler); HttpResponseMessage httpResponse = null; PullRequestResponse prResponse = new PullRequestResponse(); bool repeatRequest = true; while (repeatRequest) { // Need a new request message every time HttpRequestMessage httpRequest = new HttpRequestMessage(); // Always add User-Agent header by default httpRequest.Headers.Add("User-Agent", "RepoBrowserService"); // Now make any transformations try { if (!transformationService.BeforeRequest(pullRequest, httpRequest)) { return(prResponse); } } catch (Exception ex) { throw new InvalidOperationException("Before making the request the custom transformation service threw an exception: " + ex.Message); } // Call the authentication transformation try { if (authService != null) { authService.BeforeRequest(httpRequest); httpResponse = await httpClient.SendAsync(httpRequest); authService.AfterResponse(httpResponse); } else { httpResponse = await httpClient.SendAsync(httpRequest); } } catch (Exception ex) { throw new InvalidOperationException("There was an error while making the actual web request: " + ex.Message); } try { repeatRequest = transformationService.AfterResponse(httpResponse, prResponse); } catch (Exception ex) { throw new InvalidOperationException("After receiving the response the custom transformation service threw an exception: " + ex.Message); } } return(prResponse); }