Skip to content

Instantly share code, notes, and snippets.

View scottmcarthur's full-sized avatar

Scott McArthur scottmcarthur

  • Edinburgh, United Kingdom
View GitHub Profile
@scottmcarthur
scottmcarthur / program.cs
Created February 9, 2014 12:23
Transparent encoding/decoding Id properties in ServiceStack v4
using System;
using ServiceStack;
using System.Text;
using ServiceStack.Web;
namespace ComplexIdTest
{
class MainClass
{
public static void Main()
@scottmcarthur
scottmcarthur / ServiceStackIsolatedAppHostTest.cs
Created September 25, 2014 15:34
ServiceStack AppHost Running in it's own AppDomain for Tests
using System;
using ServiceStack;
using System.Runtime.Remoting;
using NUnit.Framework;
namespace MyApp.Tests
{
public class AppHost : AppSelfHostBase
{
public AppHost(): base("My ServiceStack Service", typeof(AppHost).Assembly)
@scottmcarthur
scottmcarthur / app.ts
Last active August 15, 2019 12:39
How to use AngularJS ng.resource.IResource with TypeScript.
/// <reference path="angular.d.ts" />
/// <reference path="angular-resource.d.ts" />
interface IEmployee extends ng.resource.IResource<IEmployee>
{
id: number;
firstName : string;
lastName : string;
}
interface IEmployeeResource extends ng.resource.IResourceClass<IEmployee>
@scottmcarthur
scottmcarthur / program.cs
Created February 1, 2014 09:26
ServiceStack IoC injection example (v4)
using System;
using ServiceStack;
namespace Tests.Recipe
{
class MainClass
{
public static void Main()
{
// Very basic console host
@scottmcarthur
scottmcarthur / App.ts
Created February 17, 2014 14:33
Source code for http://stackoverflow.com/questions/21796849/angularjs-typescript-routing (Not my personal TypeScript format)
/// <reference path="angular.d.ts" />
/// <reference path="angular-route.d.ts" />
'use strict';
// Create and register modules
var modules = ['app.controllers','app.directives', 'app.filters', 'app.services'];
modules.forEach((module) => angular.module(module, []));
// *** Push ngRoute or $routeProvider won't work ***
@scottmcarthur
scottmcarthur / Program.cs
Created April 29, 2014 09:13
Sending complex data to ServiceStack from HTML form synchronously. (ServiceStack v4)
using System;
using ServiceStack;
using ServiceStack.Web;
using ServiceStack.Text;
namespace v4
{
class MainClass
{
public static void Main()
@scottmcarthur
scottmcarthur / CheckDatabaseModel.cs
Last active January 4, 2016 08:38
How to automatically detect database model changes in ServiceStack.OrmLite, and have the database update automatically.
public void CheckDatabaseModel(Type modelType)
{
// Get the referenced model version
string modelVersion = Assembly.GetAssembly(modelType).GetName().Version.ToString();
// Determine the last model version number from the configuration
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var lastModelVersion = config.AppSettings.Settings["DatabaseModelVersion"];
// Determine if the model has changed
@scottmcarthur
scottmcarthur / Program.cs
Created January 23, 2014 12:00
Basic Authentication, Multiple repositories - ServiceStack v4
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Auth;
using ServiceStack.Web;
using System.Net;
using System.Text;
using System.Collections.Generic;
namespace Testv4
@scottmcarthur
scottmcarthur / Program.cs
Last active January 4, 2016 02:39
Deferred Validation Example. This example uses a custom validator plugin that is a substitute for the ServiceStack standard ValidationFeature plugin. When a custom attribute of `MyRoleAttribute` is applied to the request DTO, then the validation will not be run, allowing the MyRoleAttribute to run the validation checks once it has completed. Req…
using System;
using System.Linq;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
using ServiceStack.Common.Web;
using ServiceStack.Logging;
using ServiceStack.FluentValidation.Results;
using ServiceStack.Text;
using ServiceStack.ServiceInterface.Validation;
@scottmcarthur
scottmcarthur / ServiceStackApp.cs
Created January 13, 2014 12:51
ServiceStack Upload with Multipart. (Working)
using System;
using ServiceStack;
namespace Testv4
{
class MainClass
{
public static void Main()
{
var appHost = new AppHost(500);