Skip to content

Instantly share code, notes, and snippets.

View yemrekeskin's full-sized avatar
🎯
Focusing

yunus emre keskin yemrekeskin

🎯
Focusing
View GitHub Profile
@yemrekeskin
yemrekeskin / Multiton Design Pattern.cs
Last active December 15, 2015 09:39
Multiton Design pattern
namespace Multiton.Pattern
{
public sealed class Sample
{
static Dictionary<string, Sample> _instances = new Dictionary<string, Sample>();
// the key type of dictionary collection can be int,string etc.
static object _lock = new object();
private Sample()
public class DomesticPaymentRepository
: BaseRepository<Payment>
{
}
public class ForeignPaymentRepository
:BaseRepository<Payment>
{
@yemrekeskin
yemrekeskin / Bridge Design Pattern.cs
Last active December 15, 2015 15:19
example scenario for using bridge design pattern
/// <summary>
/// implementor
/// </summary>
public interface IFormatter
{
}
/// <summary>
/// concrete implementor
@yemrekeskin
yemrekeskin / Context Factory.cs
Last active December 15, 2015 22:19
Using Context Factory
public interface IContextFactory
{
SampleContext GetContext();
}
public class ContextFactory
:IContextFactory,IDisposable
{
private SampleContext _sampleContext;
@yemrekeskin
yemrekeskin / Repository Design Pattern.cs
Last active December 15, 2015 22:19
Using Repository Design Pattern
// Repository Pattern
public interface IRepository<TObject>
{
IQueryable<TObject> All();
IQueryable<TObject> Filter(Expression<Func<TObject, bool>> predicate);
IQueryable<TObject> Filter<Key>(Expression<Func<TObject, bool>> filter,
out int total, int index = 0, int size = 50);
bool Contains(Expression<Func<TObject, bool>> predicate);
TObject Find(params object[] keys);
TObject Find(Expression<Func<TObject, bool>> predicate);
@yemrekeskin
yemrekeskin / Unit Of Work Design Pattern.cs
Last active December 15, 2015 22:19
Using Unit Of Work Design Pattern
// using Unit Of Work Pattern
public interface IUnitOfWork
{
void Commit();
}
/// <summary>
/// Universal Repository de diyebiliriz
/// </summary>
public class UnitOfWork
@yemrekeskin
yemrekeskin / Null Object Design Pattern.cs
Last active December 16, 2015 01:18
Null Object Pattern Implementing
public abstract class StaffBase
{
public abstract string IdentityNumber { get; set; }
public abstract string FullName { get; set; }
public abstract string Department { get; set; }
public abstract int EfficiencyScore();
public abstract Dictionary<int, string> TaskStatus();
#region Null Implementation
@yemrekeskin
yemrekeskin / Identity Map Design Pattern.cs
Created May 1, 2013 18:05
Identity Map Design Pattern
public abstract class BaseEntity
{
// Default identity(key) for Each Object
public int Id { get; set; }
// Basic properties
public DateTime CreateDate { get; set; }
public DateTime UpdateDate{ get; set; }
public bool IsActive { get; set; }
}
public abstract class Message { }
public class BaseReponseMessage
:Message
{
}
public class BaseRequestMessage
:Message
{
public class BaseMessage
{
Guid moduleReference;
public Guid ModuleReference
{
get { return moduleReference; }
set { moduleReference = value; }
}
int processReference;