Skip to content

Instantly share code, notes, and snippets.

@Layoric
Layoric / basicAuthTest
Created September 7, 2014 09:14
SS Basic authentication
[TestFixture]
public class UnitTests
{
private readonly ServiceStackHost appHost;
public UnitTests()
{
appHost = new TestAppHost();
appHost.Init().Start("http://*:10100/");
}
@Layoric
Layoric / getasync.cs
Created August 20, 2015 06:04
ServiceStack JsonServiceClient GetAsync example snippet
client.GetAsync<CustomersResponse>("/customers").Success(response => {
foreach(var c in response.Customers) {
Console.WriteLine(c.CompanyName);
}
}).Error(exception => {
Console.WriteLine(exception.Message);
});
@Layoric
Layoric / AppHost.cs
Last active May 25, 2016 14:04
A very simple webhook integration with Slack and ServiceStack response filters
//Example use AppHost
public class AppHost : AppHostBase
{
public AppHost()
: base("SlackPluginExample", typeof(MyServices).Assembly) { }
public override void Configure(Container container)
{
this.Plugins.Add(new SlackNotifierFeature
{
@Layoric
Layoric / HelloWorld.cs
Created December 5, 2015 04:05
ServiceStack Model routes example
[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
@Layoric
Layoric / pom.xml
Created April 18, 2016 03:11
Apache Felix basic POM config
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the
NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF
licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing
@Layoric
Layoric / main.cs
Created August 21, 2016 01:35
New Public Gist
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
public class GithubRepository
{
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public string Homepage { get; set; }
@Layoric
Layoric / index.md
Last active August 25, 2016 03:30
Using ServiceStack.Redis on .NET Core
@Layoric
Layoric / main.cs
Created August 25, 2016 03:15
Initializing your Redis connection.
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
public class GithubRepository
{
public string Name { get; set; }
public string Description { get; set; }
public string Url { get; set; }
public string Homepage { get; set; }
@Layoric
Layoric / main.cs
Last active August 25, 2016 03:31
Initializing your Redis connection.
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.Redis;
var redisManagerPool = new RedisManagerPool("localhost:6379");
using(var client = redisManagerPool.GetClient())
{
client.Info.PrintDump();
@Layoric
Layoric / index.md
Last active September 1, 2016 02:46
Auto mapping

Auto mapping

Auto mapping it a helpful utility in ServiceStack that allows you to easy populate different classes with the same structure allowing you to keep appropriate separations whilst reducing lines of code.

For example, it's common in ServiceStack to keep your request and response DTO classes separate from others like your OrmLite model classes or other logic classes even thought they might share the same structure.

public class GetPersonResponse
{
 public string FirstName { get;set; }