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
/// <summary> | |
/// Creates a connection adapter that cancels any <see cref="IDbCommand"/> created from it when the client disconnects from the response. | |
/// </summary> | |
private class ClientDisconnectedConnectionAdapter : IDbConnection | |
{ | |
private readonly SqlConnection _connection; | |
public conn(SqlConnection sqlConnection) | |
{ | |
_connection = sqlConnection ?? throw new ArgumentNullException(nameof(sqlConnection)); |
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
using ImageResizer; | |
using ImageResizer.Configuration; | |
using ImageResizer.Encoding; | |
using ImageResizer.Plugins; | |
using System.Collections.Generic; | |
using System.Drawing; | |
using System.Drawing.Imaging; | |
using System.IO; | |
namespace ImageResizer.CustomPlugins |
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 class DelegatingStream : Stream | |
{ | |
Stream stream; | |
protected DelegatingStream(Stream stream) | |
{ | |
if (stream == null) | |
throw new ArgumentNullException("stream"); | |
this.stream = stream; |
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
const createPaginator = (endpoint, resultKey) => { | |
const createRequestPageActionCreator = (endpoint, resultKey) => (page) => requestPage(endpoint, resultKey, page) | |
const requestPage = (page) => ({ | |
type: 'REQUEST_PAGE', | |
payload: { | |
page | |
}, | |
meta: { |
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 LinqExtensions | |
{ | |
public static IQueryable<TSource> Page<TSource>(this IQueryable<TSource> source, IPageable pageable) | |
{ | |
return Page<IQueryable<TSource>, TSource>(source, pageable); | |
} | |
public static IQueryable<TSource> Page<TSource>(this IQueryable<TSource> source, int page, int maxPerPage = 10) | |
{ | |
return Page<IQueryable<TSource>, TSource>(source, page, maxPerPage); |
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 DataModel GetDataModel(int id) | |
{ | |
const string sql = "map.GetDataModel @id=@id"; | |
using (DbContext context = new DbContext(_connectionString)) | |
{ | |
using (GridReader reader = new GridReader(context, sql, new SqlParameter("@id", id))) | |
{ | |
DataModel model = reader.Read<DataModel>().FirstOrDefault(); | |
model.NestedArray = reader.Read<Nested>().ToArray(); |
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 class CommandInterceptionOptions | |
{ | |
public CommandInterceptionOptions() | |
{ | |
WarningThreshold = TimeSpan.FromSeconds(2); | |
} | |
public TimeSpan WarningThreshold { get; set; } | |
public static CommandInterceptionOptions Default = new CommandInterceptionOptions(); |
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
using System; | |
namespace MvcApplication1 | |
{ | |
public class BindAsAttribute : Attribute | |
{ | |
public BindAsAttribute(Type modelType) | |
{ | |
ModelType = modelType; | |
} |
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 abstract class AsyncTraceListener : TraceListener | |
{ | |
public AsyncTraceListener() | |
{ | |
_loggingThread = new Thread(new ThreadStart(ProcessQueue)) | |
{ | |
// this is performed from a bg thread, to ensure the queue is serviced from a single thread | |
IsBackground = true | |
}; | |
_loggingThread.Start(); |
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 class WebConfiguration | |
{ | |
public WebConfiguration(string path = "~", bool autoSave = true, bool autoRefresh = true) | |
{ | |
if (string.IsNullOrWhiteSpace(path)) | |
throw new ArgumentNullException("path"); | |
_autoSave = autoSave; | |
_autoRefresh = autoRefresh; | |
_configuration = Open(path); |
NewerOlder