Skip to content

Instantly share code, notes, and snippets.

Avatar

glikoz

View GitHub Profile
View Graph.cs
class Program
{
static void Main(string[] args)
{
var virtualBroker = new VirtualBroker();
var coolStrategy = new CoolStrategy();
var anotherCoolStrategy = new AnotherCoolStrategy();
var graph = RunnableGraph.FromGraph(GraphDsl.Create(b =>
{
var input = b.Add(Source.From(new[] { new TickData(11, 12), new TickData(12, 13) })); //FAIL- Must be dynamic Queue
View Program.cs
class Program
{
static ActorSystem System;
static int loop = 1000;
static int maxParallel=100;//For Parallel Foreach
static int taskload = 50;
static void Main(string[] args)
{
View RedisRepository.cs
[DependencyRegisterar(Lifetime = LifetimeManagers.PerRequest)]
public class RedisRepository : IRedisClientsManager, IBasicPersistenceProvider
{
#region Members
private const string CONFIGURATION_PREFIX = "cfg:";
private const string PERFORMANCE_PREFIX = "prf:";
private const string HASHSET_PREFIX = "set:";
private IRedisClientsManager _Manager;
View PerRequestLifetimeManager.cs
/// <summary>
/// Represents a lifetime manager for request base life time management
/// </summary>
public class PerRequestLifetimeManager : LifetimeManager
{
#region Members
private LifetimeManager _WrappedLifetimeManager;
#endregion
View DbOperationContext.cs
/// <summary>
/// Represents a context class for db operations
/// </summary>
public class DbOperationContext : IDisposable
{
#region Members
private object syncRoot = new object();
private int _TransactionCount;
private Dictionary<Type, object> _TypedClients = new Dictionary<Type, object>();
@glikoz
glikoz / BaseController.cs
Created Jun 27, 2012
Base Controller for ServiceStack
View BaseController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ServiceStack.Mvc;
using ServiceStack.ServiceInterface.Auth;
using ServiceStack.ServiceInterface;
using ServiceStack.ServiceHost;
@glikoz
glikoz / UserAuthExtensions.cs
Created Jun 26, 2012
ServiceStack UserAuthExtensions
View UserAuthExtensions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceStack.ServiceInterface.Auth;
using ServiceStack.Text;
namespace ServiceStack.ServiceInterface.Auth
{
public static class UserAuthExtensions
View threadinsert.cs
private void ThreadedInsert(object obj)
{
RedisClient redis = new RedisClient(TestConfig.SingleHost);
Article a = new Article() { Name = "I Love Writing Test" };
a.Id = redis.As<Article>().GetNextSequence();
redis.Watch("idx:article:" + a.Name);
using (var trans = redis.CreateTransaction())
{
@glikoz
glikoz / gen.cs
Created Jun 1, 2012
Generic interface registration
View gen.cs
container.Register <IRep<T>>(c => new Rep<T>())); /// Exception :)
container.RegisterAllTypesOf<IRep> (....)
@glikoz
glikoz / Test.cs
Created May 31, 2012
Usage of Container out of Controller
View Test.cs
public class MyProvider
{
public IRepository MyRepository {get;set;}
public MyProvider()
{
// Registration made in AppHost as container.Register<IRepository>(c => new MyRepository ());
MyRepository= new Container().Resolve(IRepository); // a)Concrete Service Locator
MyRepository= Funq.Container.Resolve(IRepository); // b)Service Locator check this http://blog.ploeh.dk/2010/02/03/ServiceLocatorIsAnAntiPattern.aspx