/// <inheritdoc /> public GitItem GetItem(SourceInformation searchInformation) { searchInformation.AssertIsValid(); Validators.AssertIsNotNull(_client, "GitHttpClient"); Logger.Trace("Entering"); var info = $"{nameof(searchInformation)}: {searchInformation}"; var result = WaitAndRetryPolicy.ExecuteAndCapture( _ => IgnoreExceptionsHelper.DoMethodIgnoringExceptions <GitItem>( new Func <SourceInformation, GitItem>(GetItemWrapper), new[] { typeof(VssServiceException) }, searchInformation ), MakeContext(info)); HandlePolicyResult(result, info); var output = result.Result; Logger.Trace("Exiting"); return(output); }
/// <inheritdoc /> public string GetItemContent(SourceInformation sourceInformation) { sourceInformation.AssertIsValid(); Validators.AssertIsNotNull(_client, "GitHttpClient"); Logger.Trace("Entering"); string output = null; var info = $"{nameof(sourceInformation)}: {sourceInformation}"; var result = WaitAndRetryPolicy.ExecuteAndCapture( _ => IgnoreExceptionsHelper.DoMethodIgnoringExceptions <Stream>( new Func <SourceInformation, Stream>(GetItemContentWrapper), new[] { typeof(VssServiceException) }, sourceInformation ), MakeContext(info)); HandlePolicyResult(result, info); var contentStream = result.Result; if (contentStream != null) { var reader = new StreamReader(contentStream); output = reader.ReadToEnd(); } Logger.Trace("Exiting"); return(output); }
/// <inheritdoc /> public string GetItemContent(SourceInformation sourceInformation) { sourceInformation.AssertIsValid(); sourceInformation.AssertIsSourceType(SourceType.TfsVc); Logger.Trace("Entering"); //var stream = _tfVcClient.GetItemContentAsync(searchInformation.SourcePath).Result; var stream = IgnoreExceptionsHelper.DoMethodIgnoringExceptions <Stream>( new Func <string, Stream>(GetItemContentAsyncWrapper), new[] { typeof(VssServiceException) }, sourceInformation.SourcePath ); string output = null; if (stream != null) { using (var reader = new StreamReader(stream)) { output = reader.ReadToEnd(); } } return(output); }
public static void DoMethodIgnoringExceptions_Returns_Null_WithIgnoredException2() { var result = IgnoreExceptionsHelper.DoMethodIgnoringExceptions <string>( new Func <string, string>(File.ReadAllText), new[] { typeof(FileNotFoundException) }, "junk filename"); Assert.That(result, Is.Null); }
public static void DoMethodIgnoringExceptions_Returns_Null_WithIgnoredException1() { var result = IgnoreExceptionsHelper.DoMethodIgnoringExceptions <string>( new Func <Type, string>(ExampleMethod), new[] { typeof(ArgumentException) }, typeof(ArgumentException)); Assert.That(result, Is.Null); }
public static void DoMethodIgnoringExceptions_Throws_WithNonIgnoredException2() { Assert.That( () => IgnoreExceptionsHelper.DoMethodIgnoringExceptions <string>( new Func <string, string>(File.ReadAllText), new[] { typeof(ArgumentNullException) }, "junk filename"), Throws.TypeOf <FileNotFoundException>()); }
public static void DoMethodIgnoringExceptions_Throw_WithBadException() { Assert.That( () => IgnoreExceptionsHelper.DoMethodIgnoringExceptions <string>( new Func <Type, string>(ExampleMethod), new[] { typeof(string) }, typeof(InvalidOperationException)), Throws.ArgumentException ); }
public static void DoMethodIgnoringExceptions_Returns_Value_WithNoException1() { var result = IgnoreExceptionsHelper.DoMethodIgnoringExceptions <string>( new Func <Type, string>(ExampleMethod), new[] { typeof(ArgumentException) }, typeof(string)); Assert.That(result, Is.Not.Null); Assert.That(result.Length, Is.GreaterThan(0)); }
/// <inheritdoc /> public string GetItemContent(SourceInformation sourceInformation) { Validators.AssertIsNotNull(sourceInformation, nameof(sourceInformation)); sourceInformation.AssertIsValid(); sourceInformation.AssertIsSourceType(SourceType.Filesystem); Logger.Trace("Entering"); //var output = File.ReadAllText(searchInformation.SourcePath); var output = IgnoreExceptionsHelper.DoMethodIgnoringExceptions <string>( new Func <string, string>(File.ReadAllText), new[] { typeof(FileNotFoundException), typeof(DirectoryNotFoundException), typeof(IOException) }, sourceInformation.SourcePath ); return(output); }
/// <inheritdoc /> public TfvcItem GetItem(SourceInformation searchInformation) { Validators.AssertIsNotNull(searchInformation, nameof(searchInformation)); searchInformation.AssertIsValid(); searchInformation.AssertIsSourceType(SourceType.TfsVc); Logger.Trace("Entering"); //var output = _tfVcClient.GetItemAsync(searchInformation.SourcePath).Result; var output = IgnoreExceptionsHelper.DoMethodIgnoringExceptions <TfvcItem>( new Func <string, TfvcItem>(GetItemWrapper), new[] { typeof(VssServiceException) }, searchInformation.SourcePath ); return(output); }