Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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
        }
Esempio n. 4
0
        public Context(string dbPath)
        {
            if (!System.IO.Directory.Exists(dbPath))
            {
                System.IO.Directory.CreateDirectory(dbPath);
            }
            this.dbPath = dbPath;

            engine = ApplicationContext.Configure();
            uow    = new UnitOfWork();
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        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();
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
        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();
        }
Esempio n. 11
0
 static void Main(string[] args)
 {
     Engine e = ApplicationContext.Configure();
Esempio n. 12
0
 public AopObjectFactory()
 {
     aopEngine = ApplicationContext.Configure();
 }
Esempio n. 13
0
 /// <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());
 }
Esempio n. 14
0
 /// <summary>
 /// Create an AopEngine from app or web.config.
 /// </summary>
 /// <returns></returns>
 public static IEngine FromAppConfig()
 {
     return(ApplicationContext.Configure());
 }
Esempio n. 15
0
 /// <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));
 }
Esempio n. 16
0
 /// <summary>
 /// Not yet implemented
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns></returns>
 public static IEngine FromFile(string fileName)
 {
     return(ApplicationContext.Configure(fileName));
 }