This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master | |
DECLARE @dbName nvarchar(128); | |
DECLARE @sqlTableQuery nvarchar(max); | |
DECLARE dbsCursor CURSOR | |
LOCAL STATIC READ_ONLY FORWARD_ONLY | |
FOR | |
SELECT | |
name | |
FROM master.dbo.sysdatabases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class JilMediaTypeFormatter : MediaTypeFormatter | |
{ | |
private static readonly MediaTypeHeaderValue _applicationJsonMediaType = new MediaTypeHeaderValue("application/json"); | |
private static readonly MediaTypeHeaderValue _textJsonMediaType = new MediaTypeHeaderValue("text/json"); | |
private static readonly Task<bool> _done = Task.FromResult(true); | |
private static readonly Options _options; | |
static JilMediaTypeFormatter() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class WebApiConfig | |
{ | |
public static void Register(HttpConfiguration config) | |
{ | |
// Web API configuration and services | |
// Configure Web API to use only bearer token authentication. | |
config.SuppressDefaultHostAuthentication(); | |
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); | |
config.ConfigureJSONFormatter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class JilSerializationAttribute : Attribute, IControllerConfiguration | |
{ | |
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) | |
{ | |
// Register JilMediaTypeFormatter for controller | |
controllerSettings.Formatters.Insert(0, new JilMediaTypeFormatter()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class JilSerializationAttribute : Attribute, IControllerConfiguration | |
{ | |
public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) | |
{ | |
// Register JilMediaTypeFormatter for controller | |
controllerSettings.Formatters.Insert(0, new JilMediaTypeFormatter()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[JilSerialization] | |
public sealed class JilValuesController : ApiController | |
{ | |
// GET api/values | |
public IHttpActionResult Get() | |
{ | |
return Ok(ValueServices.Values); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Retry<TException>(Action action, int maxAttempts, TimeSpan delay, | |
Func<TException, bool> shouldRetry = null, Action<TException> exceptionLogger = null) | |
where TException : Exception | |
{ | |
Assert.Positive(maxAttempts, nameof(maxAttempts)); | |
Assert.NotNull(action, nameof(action)); | |
bool shouldRetryNotNull = shouldRetry != null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RetryHandler.Retry<WebException>(() => | |
{ | |
string content = DownloadContent(); | |
Console.Write(content); | |
}, 6, 500, httpRequestException => httpRequestException.Status == WebExceptionStatus.Timeout | |
|| httpRequestException.Status == WebExceptionStatus.ConnectFailure, Logger); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void RetryFor<TException>(Action action, TimeSpan duration, TimeSpan delay, | |
Func<TException, bool> shouldRetry = null, Action<TException> exceptionLogger = null) | |
where TException : Exception | |
{ | |
Assert.NotNull(action, nameof(action)); | |
bool shouldRetryNotNull = shouldRetry != null; | |
double durationTotalMs = duration.TotalMilliseconds; | |
DateTime startDateTime = DateTime.Now; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RetryHandler.RetryFor<WebException>(() => | |
{ | |
string content = DownloadContent(); | |
Console.Write(content); | |
}, TimeSpan.FromSeconds(75), TimeSpan.FromSeconds(2), httpRequestException => httpRequestException.Status == WebExceptionStatus.Timeout | |
|| httpRequestException.Status == WebExceptionStatus.ConnectFailure, Logger); |
OlderNewer