Esempio n. 1
0
        static void Main()
        {
            ApplicationActivator.UseEnvironment(EnvironmentName.Development).Startup();

            try
            {
                Console.WriteLine("Accessing the ICacheServiceWithBehavior...");
                var service1 = ServiceContainer.GetInstance <ICacheServiceWithBehavior>();
                Console.WriteLine("ICacheServiceWithBehavior returns value: " + service1.GetVale("Sample"));

                Console.WriteLine("Accessing the ICacheServiceWithContractAttribute...");
                var service2 = ServiceContainer.GetInstance <ICacheServiceWithContractAttribute>();
                Console.WriteLine("ICacheServiceWithContractAttribute returns value: " + service2.GetVale("Sample"));

                Console.WriteLine("Accessing the ICacheServiceWithFactory...");
                var service3 = ServiceContainer.GetInstance <ICacheServiceWithFactory>();
                Console.WriteLine("ICacheServiceWithFactory returns value: " + service3.GetVale("Sample"));

                Console.WriteLine("Accessing the ICacheServiceWithServiceAttribute...");
                var service4 = ServiceContainer.GetInstance <ICacheServiceWithServiceAttribute>();
                Console.WriteLine("ICacheServiceWithServiceAttribute returns value: " + service4.GetVale("Sample"));

                Console.WriteLine("Success");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.GetType().FullName);
                Console.Error.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }
Esempio n. 2
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
            ApplicationActivator.UseEnvironment(env.EnvironmentName);
        }
Esempio n. 3
0
 protected void Application_Start(object sender, EventArgs e)
 {
     ApplicationActivator.UseEnvironment(EnvironmentName.Development).Startup();
     RegisterRoutes(RouteTable.Routes);
     ServiceContainer.GetInstance <ICacheRepository>().SetVale("Sample", "ServiceBridge");
 }