static void Main(string[] args) { IContainer c = ApplicationContext.Configure(); SomeClass some1 = (SomeClass)c.GetObject("MySomeClass"); SomeClass some2 = (SomeClass)c.GetObject("MySomeClass"); if (some1 == some2) { Console.WriteLine("same"); } else { Console.WriteLine("not same"); } if (some1.ListPropp == some2.ListPropp) { Console.WriteLine("same"); } else { Console.WriteLine("not same"); } ListProppClass listpropp = (ListProppClass)c.GetObject("MyListProppClass"); Console.WriteLine(listpropp.SomeStringProp); Console.ReadLine(); }
static void Main(string[] args) { IContainer container = ApplicationContext.Configure(); SomeClass myObject = container.GetObject <SomeClass>("MyObject"); //this is a simple ctor injection sample //see SomeClass.cs for more info Console.ReadLine(); }
static void Main(string[] args) { IEngine c = ApplicationContext.Configure(); SomeAopTarget target = (SomeAopTarget)c.CreateProxy(typeof(SomeAopTarget)); target.ReturnAString(0); target.ReturnAString(1); //fails since method tries to return null target.ReceiveAString(10, "hello"); target.ReceiveAString(10, null); //fails since "def" may not be null }
public Context(string dbPath) { if (!System.IO.Directory.Exists(dbPath)) { System.IO.Directory.CreateDirectory(dbPath); } this.dbPath = dbPath; engine = ApplicationContext.Configure(); uow = new UnitOfWork(); }
static void Main(string[] args) { IEngine c = ApplicationContext.Configure(); //create an instance of "SomeAopTarget" through the aop container SomeAopTarget myObj = c.CreateProxy(typeof(SomeAopTarget)) as SomeAopTarget; //this method will be called async , because of the async interceptor myObj.DoSomeHeavyWork(100); //this method will finish BEFORE the above method! myObj.SayHelloAop(); Console.WriteLine("press any key to continue"); Console.ReadLine(); }
static void Main(string[] args) { IContainer container = ApplicationContext.Configure(); SomeClass myObject = container.GetObject <SomeClass>("MyObject"); Console.WriteLine("AStringProperty = {0}", myObject.AStringProperty); Console.WriteLine("ADateTimeProperty = {0}", myObject.ADateTimeProperty); //lets see whats in the list property foreach (object item in myObject.SomeListProperty) { Console.WriteLine("element = {0}", item); } Console.ReadLine(); }
private static void Main(string[] args) { IEngine c = ApplicationContext.Configure(); IMyTestClass t = c.CreateProxy(typeof(MyTestClass)) as IMyTestClass; int a = 6666; t.DoStuff1(out a); Console.WriteLine("a={0}", a); t.DoStuff2(1); t.DoStuff2(2); t.DoStuff2(3); t.DoStuff2(100, "hej"); Console.WriteLine("done"); Console.ReadLine(); }
private static void Main() { IEngine e = ApplicationContext.Configure(); //create an instance of "SomeAopTarget" through the aop container SomeAopTarget myObj = e.CreateProxy <SomeAopTarget>(); myObj.PerfromSomeReallyHeavyCalculation(1); myObj.NonAopVersion(1); //for (int i = 0; i < 4; i++) //{ // DateTime start = DateTime.Now; // Console.WriteLine("starting to do some heavy calculation"); // double res = myObj.PerfromSomeReallyHeavyCalculation(50); //<-- just a normal call to our method // Console.WriteLine(res); // Console.WriteLine("heavy calculation done"); // DateTime end = DateTime.Now; // Console.WriteLine("time to complete work: {0}", end.Subtract(start)); //} Stopwatch timer = new Stopwatch(); timer.Start(); for (int i = 0; i < 1000000; i++) { double res = myObj.PerfromSomeReallyHeavyCalculation(1); } timer.Stop(); Console.WriteLine("Time elapsed on non aop version {0}", timer.ElapsedMilliseconds); timer = new Stopwatch(); timer.Start(); for (int i = 0; i < 1000000; i++) { double res = myObj.NonAopVersion(1); } timer.Stop(); Console.WriteLine("Time elapsed on non aop version {0}", timer.ElapsedMilliseconds); Console.WriteLine("press any key to continue"); Console.ReadLine(); }
static void Main(string[] args) { IEngine e = ApplicationContext.Configure(); //create an instance of "SomeAopTarget" through the aop container SomeAopTarget myObj = e.CreateProxy(typeof(SomeAopTarget)) as SomeAopTarget; for (int i = 0; i < 4; i++) { DateTime start = DateTime.Now; Console.WriteLine("starting to do some heavy calculation"); double res = myObj.PerfromSomeReallyHeavyCalculation(50); //<-- just a normal call to our method Console.WriteLine(res); Console.WriteLine("heavy calculation done"); DateTime end = DateTime.Now; Console.WriteLine("time to complete work: {0}", end.Subtract(start)); } Console.WriteLine("press any key to continue"); Console.ReadLine(); }
static void Main(string[] args) { IContainer container = ApplicationContext.Configure(); SomeClass myObject = container.GetObject <SomeClass>("MyObject"); myObject.DoStuff(); Console.WriteLine("MyObject.Some.Property.Path = {0}", myObject.Some.Property.Path); //get MyObject again from the container SomeClass myObject2 = container.GetObject <SomeClass>("MyObject"); if (myObject == myObject2) { Console.WriteLine("myObject and myObject2 is the same instance"); } else { Console.WriteLine("myObject and myObject2 are two different instances"); //<- because its marked as PerGraph in the config } if (myObject.LogManager == myObject2.LogManager) { Console.WriteLine("myObject.LogManager and myObject2.LogManager is the same instance"); //<- because its marked as PerContainer in the config } else { Console.WriteLine("myObject.LogManager and myObject2.LogManager are two different instances"); } Console.ReadLine(); }
static void Main(string[] args) { Engine e = ApplicationContext.Configure();
public AopObjectFactory() { aopEngine = ApplicationContext.Configure(); }
/// <summary> /// Not yet implemented /// </summary> /// <param name="subSectionName">Name of a subsection in the config.</param> /// <returns></returns> public static IEngine FromAppConfig(string subSectionName) { return(ApplicationContext.Configure()); }
/// <summary> /// Create an AopEngine from app or web.config. /// </summary> /// <returns></returns> public static IEngine FromAppConfig() { return(ApplicationContext.Configure()); }
/// <summary> /// /// </summary> /// <param name="fileName"></param> /// <param name="useTypePlaceHolders"></param> /// <returns></returns> public static IEngine FromFile(string fileName, bool useTypePlaceHolders) { return(ApplicationContext.Configure(fileName, useTypePlaceHolders)); }
/// <summary> /// Not yet implemented /// </summary> /// <param name="fileName"></param> /// <returns></returns> public static IEngine FromFile(string fileName) { return(ApplicationContext.Configure(fileName)); }