public static IContainer Register()
        {
            var container = Bootstraper.Initialize <SimpleWebApiModule>();

            // ASP.Net Wep.API and ASP.NET MVC use two different IDependencyResolver
            // (because they designed the Wep.API to not depend on ASP.NET MVC)
            // More info: http://stackoverflow.com/questions/12276913/mvc-web-api-not-working-with-autofac-integration
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            return(container);
        }
        public static void Startup(string[] commandLine, IEnumerable <Package> packages)
        {
            Bootstraper.Initialize(commandLine, packages.Select(p => new PackageStartupInfo
            {
                Id           = p.Id,
                Version      = p.Version,
                Module       = p.IsModulePackage ? p.MainAssembly?.LazyAssembly : null,
                Dependencies = p.Dependencies.ToDictionary(d => d.Id, d => d.Version, StringComparer.OrdinalIgnoreCase)
            }), new PackageStorage(ManifestUtil.TargetFrameworks));

            Bootstraper.Startup();
        }
Exemple #3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton(_ => Configuration);
     Bootstraper.Initialize();
     Bootstraper.Configure(services);
     services.AddCors(options =>
     {
         options.AddPolicy("CorsPolicy",
                           corsPolicyBuilder => corsPolicyBuilder
                           .AllowAnyOrigin()
                           .AllowAnyMethod()
                           .AllowAnyHeader()
                           .AllowCredentials());
     });
     services.AddMvc();
 }
Exemple #4
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            var container = new UnityContainer();

            config.DependencyResolver = new UnityResolver(container);

            Bootstraper bootstraper = new Bootstraper(container);

            bootstraper.Initialize();

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
        static void Main(string[] args)
        {
            //Init Required Component & Service
            var container = Bootstraper.Initialize();
            var uiHandle  = new UIHandle();

            DataBaseHandle.Init();
            var vendorService   = container.Resolve <IVendorService>();
            var customerService = container.Resolve <ICustomerService>();

            do
            {
                uiHandle.RenderIndexPage();

                //Select Actions
                int selectedUserType = Convert.ToInt16(Console.ReadLine());

                switch (selectedUserType)
                {
                case 1:     //Vendor
                    #region Vendor Functions

                    do
                    {
                        // Show vendor actions
                        uiHandle.RenderVendorAction();

                        //Select Actions
                        int selectedAction = Convert.ToInt16(Console.ReadLine());

                        try
                        {
                            switch (selectedAction)
                            {
                            case 1:
                                GetMarketItemsAction(vendorService, uiHandle);
                                break;

                            case 2:
                                UpdateStockItemsInformation(vendorService, uiHandle);
                                break;

                            case 3:
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    } while (true);
                    #endregion
                    continue;

                case 2:     //Customer
                    #region Customer Functions

                    do
                    {
                        uiHandle.RenderCustomerAction();

                        //Select Actions
                        int selectedAction = Convert.ToInt16(Console.ReadLine());

                        if (selectedAction == 2)
                        {
                            break;
                        }

                        var publishItems = customerService.GetPublishItems();

                        uiHandle.RenderPublishItem(publishItems);

                        RemoveStockItem(customerService, uiHandle, publishItems);
                    } while (true);
                    break;

                    #endregion
                default:
                    Console.WriteLine("User Type not exists");
                    break;
                }
            } while (true);
        }