Esempio n. 1
0
        static void Main(string[] args)
        {
            TextWriterTraceListener tr1 = new TextWriterTraceListener(System.Console.Out);

            Debug.Listeners.Add(tr1);

            using (var container = new UnityContainer())
            {
                Console.WriteLine("# Performing Registrations...");
                ContainerBootstrapper.RegisterTypes(container);
                Console.WriteLine("Container has {0} Registrations:", container.Registrations.Count());

                foreach (ContainerRegistration item in container.Registrations)
                {
                    Console.WriteLine(item.GetMappingAsString());
                }

                Console.WriteLine();
                Console.ReadLine();

                Console.WriteLine("# Performing type resolutions...");
                container.Resolve <ISurveyStore>().Initialize();
                //container.Resolve<ISurveyAnswerStore>().Initialize();
                //container.Resolve<ITenantStore>().Initialize();

                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
Esempio n. 2
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            // container.LoadConfiguration();

            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();
            ContainerBootstrapper.RegisterTypes(container);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            TelemetryClient = new TelemetryClient();

            this.container = new UnityContainer();
            ContainerBootstrapper.RegisterTypes(this.container);

            IAppSettingsService settings = this.container.Resolve <IAppSettingsService>();

            RequestedTheme = settings.AppTheme;

            InitializeComponent();
            Suspending += OnSuspending;
            Resuming   += OnResuming;
        }
Esempio n. 4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Create UnityContainer and configure Dependency Resolver
            var unityContainer = new UnityContainer();

            DependencyResolver.SetResolver(new MvcUnityResolver(unityContainer));

            //Register all dependencies
            ContainerBootstrapper.RegisterTypes(unityContainer);
        }
Esempio n. 5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(RouteTable.Routes);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Set up Unity DI:
            var container = new UnityContainer();

            ContainerBootstrapper.RegisterTypes(container);
            GlobalConfiguration.Configuration.DependencyResolver = new UnityResolver(container);

            //Start thread that executes user code every second
            WorldUpdateWrapper.StartWorldUpdate(container);

            //Initialize database with test data
            Database.SetInitializer <GameServerContext>(new DBInitializer());
        }
Esempio n. 6
0
        public static void Register(HttpConfiguration config)
        {
            //Create UnityContainer and configure Dependency Resolver
            var unityContainer = new UnityContainer();

            config.DependencyResolver = new UnityResolver(unityContainer);

            // CORS
            //config.EnableCors(new EnableCorsAttribute("http://localhost:54440", "Origin,X-Requested-With,Content-Type,Accept", "GET,POST,PUT,PATCH,DELETE,SEARCH"));

            //Register all dependencies
            ContainerBootstrapper.RegisterTypes(unityContainer);

            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.Routes.MapHttpRoute(
                name: "DefaultApiAction",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional });

            config.Routes.MapHttpRoute(
                name: "DefaultApiActionTwoParam",
                routeTemplate: "api/{controller}/{action}/{sd}/{fd}",
                defaults: new { controller = "reports", action = "GetQuaterlyReport", sd = RouteParameter.Optional, fd = RouteParameter.Optional });

            // Routing

            // Enable routing for AreaSampleController using GetAreaSampleById method
            //config.Routes.MapHttpRoute(
            //    name: "AreaSampleById",
            //    routeTemplate: "api/{controller}/{action}/{id}",
            //    defaults: new { controller = "AreaSample", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "QuarterlyReport",
            //    routeTemplate: "api/{controller}/{action}/{id}/{date}",
            //    defaults: new { id = RouteParameter.Optional, date = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "AreaSample",
            //    routeTemplate: "api/areaSample/{id}",
            //    defaults: new { controller = "AreaSample", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "Assessments",
            //    routeTemplate: "api/assessments/{id}",
            //    defaults: new { controller = "assessments", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "CriteriaSample",
            //    routeTemplate: "api/criteriaSample/{id}",
            //    defaults: new { controller = "criteriaSample", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "IndicatorSample",
            //    routeTemplate: "api/indicatorSample/{id}",
            //    defaults: new { controller = "indicatorSample", action = "GET", id = RouteParameter.Optional});

            //config.Routes.MapHttpRoute(
            //    name: "IndicatorScore",
            //    routeTemplate: "api/indicatorScore/{id}",
            //    defaults: new { controller = "indicatorScore", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "assessmentType",
            //    routeTemplate: "api/assessmentType/{id}",
            //    defaults: new { controller = "assessmentType", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "users",
            //    routeTemplate: "api/users/{id}",
            //    defaults: new { controller = "Users", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "Criteria",
            //    routeTemplate: "api/criteria/{id}",
            //    defaults: new { controller = "Criteria", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "Area",
            //    routeTemplate: "api/area/{id}",
            //    defaults: new { controller = "Area", action = "GET", id = RouteParameter.Optional });

            //config.Routes.MapHttpRoute(
            //    name: "Indicators",
            //    routeTemplate: "api/indicators/{id}",
            //defaults: new { controller = "Indicators", action = "GET", id = RouteParameter.Optional });

            // Enable JSON format returns
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            var jsonFormatter = config.Formatters.OfType <JsonMediaTypeFormatter>().First();

            jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();  // send json keys into camelCase style
        }
Esempio n. 7
0
        private static void Run()
        {
            var container = new UnityContainer();

            ContainerBootstrapper.RegisterTypes(container);
            var request = container.Resolve <ApiRequest>();
            var model   = new RequestModel();
            var menu    = new IMenu[]
            {
                new YahooCompanies(),
                new StockExchangeForCompanies(),
                new CurrenciesExchange(),
                new ImportCurrenciesTask(),
                new ImportCompaniesNasdaq(),
                new StockExchangeJson(),
                new StockExchangeTaskParseCsv(),
                new YahooHistoricalDataCsv(),
                new YahooHistoricalDataQuery(),
                new YahooCompanyProfile(),
                new YahooCompanyByName(),
                new YahooRssByCompanyName(),
                new YahooCompanyIncomeStatementHistory(),
                new YahooCompanyCashflowStatementHistory(),
                new YahooMajorHoldersBreakdownRequest(),
                new YahooRecommendationTrendRequest(),
                new YahooUpgradeDowngradeHistoryRequest(),
                new YahooInstitutionOwnershipRequest(),
                new YahooFinancialDataRequest(),
                new YahooCashflowStatementHistoryQuarterlyRequest(),
                new YahooCompanyIncomeStatementHistoryQuarterly(),
                new YahooCompanyProfileSummaryRequest(),
                new YahooMajorDirectHoldersRequest(),
                new YahooFundOwnershipRequest(),
                new YahooInsiderTransactionsRequest(),
                new YahooInsiderHoldersRequest(),
                new YahooBalanceSheetHistoryRequest(),
                new YahooBalanceSheetHistoryQuarterlyRequest(),
                new YahooDefaultKeyStatisticsRequest(),
                new YahooEarningsTrendRequest(),
            };

            while (true)
            {
                Console.WriteLine("Welcome to Stock Exchange Scrapper.");
                Console.WriteLine("What do you want to do?");

                // This loop creates a list of commands:
                for (var i = 0; i < menu.Length; i++)
                {
                    Console.WriteLine("{0}. {1}", i + 1, menu[i].Description);
                }

                // Read until the input is valid.
                string selected;
                int    commandIndex;
                do
                {
                    selected = Console.ReadLine();
                }while (!int.TryParse(selected, out commandIndex) || commandIndex > menu.Length);
                // Execute the command.
                menu[commandIndex - 1].Execute(request, model);
            }
        }