Skip to content

Instantly share code, notes, and snippets.

public static Uri CreateUri(int port = 80)
{
var host = Process.GetProcessesByName("fiddler").Any() ? "ipv4.fiddler" : "localhost";
var portNumber = port == 80 ? string.Empty : ":" + port;
return new Uri("http://" + host + portNumber);
}
using System.Web.Http;
using WebActivatorEx;
using SwaggerTest;
using Swashbuckle.Application;
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
namespace SwaggerTest
{
public class SwaggerConfig
@cmatskas
cmatskas / gist:14f8b052c59be9182ddd
Created April 30, 2015 10:45
Swagger documentation output
{
swagger: "2.0",
info: {
version: "v1",
title: "SwaggerTest"
},
host: "localhost:63171",
schemes: [
"http"
],
@cmatskas
cmatskas / Custom IEndpointBehavior.cs
Last active October 28, 2015 00:11
Custom IEndpointBehavior
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace APIServiceConsumer.Services
{
public class CustomInspectorBehavior : IEndpointBehavior
{
private readonly ClientMessageInspector clientMessageInspector = new ClientMessageInspector();
public string LastRequestXml
@cmatskas
cmatskas / CustomMessageInspector.cs
Last active January 11, 2021 02:04
CustomMessageInspector
using System;
using System.IO;
using System.Net;
using System.Security.Policy;
using System.ServiceModel.Channels;
using System.ServiceModel.Dispatcher;
using System.Xml;
namespace APIServiceConsumer.Services
{
@cmatskas
cmatskas / WCF CustomMessageHandler.cs
Last active August 29, 2015 14:20
WCF Custom Message handler
using APIConsumerServices.Services.CustomService;
using FluentAssertions;
using NUnit.Framework;
namespace APIConsumerServices.Services.Tests
{
[TestFixture]
public class CallServiceTest
{
// CustomClient is the wrapper around the WSDL generated proxy class
<script type="text/javascript">
$(document).ready(function() {
// The event listener for the file upload
document.getElementById('txtFileUpload').addEventListener('change', upload, false);
// Method that checks that the browser supports the HTML5 File API
function browserSupportFileUpload() {
var isCompatible = false;
if (window.File && window.FileReader && window.FileList && window.Blob) {
<div id="dvImportSegments" class="fileupload ">
<fieldset>
<legend>Upload your CSV File</legend>
<input type="file" name="File Upload" id="txtFileUpload" accept=".csv" />
</fieldset>
</div>
public bool UpdateUser(User user)
{
var existingUser = this.GetUser(user.Username);
if (existingUser == null)
{
return false;
}
existingUser.CopyValues(user);
UnitOfWork.UserRepository.Update(existingUser);
UnitOfWork.Save();
public virtual void Update(TEntity entityToUpdate)
{
var entry = this.context.Entry(entityToUpdate);
this.databaseSet.Attach(entityToUpdate);
entry.State = EntityState.Modified;
}