示例#1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            UnityConfig.RegisterComponents();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //set api endpoint
            ApiEndpoint.DefaultApi = ConfigurationManager.AppSettings["ApiEndpoint"];

            //implement ioc container

            //controller registrations
            IocContainer.ContainerBuilder.RegisterControllers(typeof(WebApiApplication).Assembly);

            //component registrations
            IocRegistration.Register();

            //build ioc container
            IocContainer.Build();

            //assign autofac dependency resolver
            DependencyResolver.SetResolver(new AutofacDependencyResolver(IocContainer.Container));
        }
        public void Setup()
        {
            IocRegistration.Register();
            Ioc.Initialise();
            var controller = Ioc.Resolve <IEmotionalTweetsController>();

            var tweets = controller.SearchTweets("hello").Result;

            _sentimentTweets = new SentimentTweetCollection(
                tweets.statuses.Select(tweet => controller.GetSentiment(tweet).Result));
        }
示例#3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddControllersWithViews();
     services.AddAppSettingsConfiguration(Configuration);
     IocRegistration.Register(services);
     // In production, the Angular files will be served from this directory
     services.AddSpaStaticFiles(configuration =>
     {
         configuration.RootPath = "ClientApp/dist";
     });
 }
示例#4
0
 public static void Initialize()
 {
     GlobalConfiguration.Configuration.DependencyResolver = ApplicationContext.Container.GetDependencyResolverWebApi();
     IocRegistration.Register(ApplicationContext.Container);
 }