using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsolApp
{
public class Singleton_Eager
{
private static SingletonEager objS = new SingletonEager();
private SingletonEager() { }
public static SingletonEager GetInstance
{
get { return objS; }
}
}
public class Singleton_Lazy
{
private static SingletonLazy objSL = null;
private SingletonLazy() { }
private static Object ObjLock = new object();
public static SingletonLazy GetInstance
{
get
{
lock (ObjLock)
{
if (objSL == null)
objSL = new SingletonLazy();
return objSL;
}
}
}
}
}
------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsolApp
{
public class facade
{
SubSystem1 _subone;
SubSystem2 _subtwo;
SubSystem3 _subthree;
public facade()
{
_subone = new SubSystem1();
_subtwo = new SubSystem2();
_subthree = new SubSystem3();
}
public void MethodA()
{
_subone.Method1();
_subtwo.Method2();
}
public void MethodB()
{
_subone.Method1();
_subthree.Method3();
}
}
public class SubSystem1
{
public void Method1()
{
Console.Write("Sub Method1 ");
}
}
public class SubSystem2
{
public void Method2()
{
Console.Write("Sub method 2");
}
}
public class SubSystem3
{
public void Method3()
{
Console.Write("Sub Method 3");
}
}
}
-----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsolApp
{
public class Tenum
{
private string[] xlist = new string[size];
int cc = 0;
static int size = 10;
public void TestEnum(int agg)
{
switch ((AggregatorType)agg)
{
case AggregatorType.DirectBank:
Console.Write(AggregatorType.DirectBank);
Console.ReadKey();
return;
case AggregatorType.SBIePay:
Console.Write(AggregatorType.SBIePay);
Console.ReadKey();
return;
case AggregatorType.ICICI:
Console.Write(AggregatorType.ICICI);
Console.ReadKey();
return;
default: Console.Write("No Aggregator");
Console.ReadKey();
return;
}
}
}
public enum AggregatorType
{
DirectBank = 0,
SBIePay = 8,
ICICI,
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsolApp
{
public class Singleton_Eager
{
private static SingletonEager objS = new SingletonEager();
private SingletonEager() { }
public static SingletonEager GetInstance
{
get { return objS; }
}
}
public class Singleton_Lazy
{
private static SingletonLazy objSL = null;
private SingletonLazy() { }
private static Object ObjLock = new object();
public static SingletonLazy GetInstance
{
get
{
lock (ObjLock)
{
if (objSL == null)
objSL = new SingletonLazy();
return objSL;
}
}
}
}
}
------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsolApp
{
public class facade
{
SubSystem1 _subone;
SubSystem2 _subtwo;
SubSystem3 _subthree;
public facade()
{
_subone = new SubSystem1();
_subtwo = new SubSystem2();
_subthree = new SubSystem3();
}
public void MethodA()
{
_subone.Method1();
_subtwo.Method2();
}
public void MethodB()
{
_subone.Method1();
_subthree.Method3();
}
}
public class SubSystem1
{
public void Method1()
{
Console.Write("Sub Method1 ");
}
}
public class SubSystem2
{
public void Method2()
{
Console.Write("Sub method 2");
}
}
public class SubSystem3
{
public void Method3()
{
Console.Write("Sub Method 3");
}
}
}
-----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestConsolApp
{
public class Tenum
{
private string[] xlist = new string[size];
int cc = 0;
static int size = 10;
public void TestEnum(int agg)
{
switch ((AggregatorType)agg)
{
case AggregatorType.DirectBank:
Console.Write(AggregatorType.DirectBank);
Console.ReadKey();
return;
case AggregatorType.SBIePay:
Console.Write(AggregatorType.SBIePay);
Console.ReadKey();
return;
case AggregatorType.ICICI:
Console.Write(AggregatorType.ICICI);
Console.ReadKey();
return;
default: Console.Write("No Aggregator");
Console.ReadKey();
return;
}
}
}
public enum AggregatorType
{
DirectBank = 0,
SBIePay = 8,
ICICI,
}
}
No comments:
Post a Comment