Example #1
0
        public static void ResolveDependencies()
        {
            var builder = new ContainerBuilder();

            AutofacDependencyResolution.RegisterTypes(builder);

            builder.RegisterControllers(Assembly.GetExecutingAssembly());

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Example #2
0
        private static void Main(string[] args)
        {
            var dateTime = DateTime.Now.AddHours(-7);

            if (args.Any())
            {
                if (!DateTime.TryParse(args[0], out dateTime))
                {
                    dateTime = DateTime.Now.AddHours(-7);
                }
            }

            var builder = new ContainerBuilder();

            AutofacDependencyResolution.RegisterTypes(builder);

            var container = builder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                var nba = scope.Resolve <INbaService>();
                nba.Run(dateTime);
            }
        }