Ejemplo n.º 1
0
        public static IContainer Initialize()
        {
            var projectPrefix = MyProjectHelper.Resolve().GetProjectPrefix();
            var container     = new Container(cfg =>
            {
                cfg.Scan(scanner =>
                {
                    //assemblies
                    scanner.AssembliesFromApplicationBaseDirectory(assembly =>
                    {
                        var name = assembly.GetName().Name;
                        return(name.StartsWith(projectPrefix) || name.StartsWith("CommonFx"));
                    });

                    //registries
                    scanner.LookForRegistries();
                });

                //global register
                cfg.For <IServiceLocator>().Use <StructureMapDependencyScope>().Singleton();
            });

            CoreServiceProvider.CurrentFunc = () => container.GetInstance <IServiceLocator>();

            ShowDebugInfo(container);

            return(container);
        }
Ejemplo n.º 2
0
        public static void AutoRegisterAreaRoutes(this AreaRegistration areaRegistration, AreaRegistrationContext context)
        {
            var myProjectHelper      = MyProjectHelper.Resolve();
            var defaultProjectPrefix = myProjectHelper.GetProjectPrefix();

            //context.MapRoute(
            //    name: areaRegistration.AreaName + "_default",
            //    url: "{site}/" + areaRegistration.AreaName + "/{controller}/{action}",
            //    defaults: new { area = areaRegistration.AreaName },
            //    namespaces: new[] { string.Format("{0}.Web.Areas.{1}.Controllers", defaultProjectPrefix, areaRegistration.AreaName) }
            //    );

            context.MapRoute(
                name: areaRegistration.AreaName + "_default",
                url: areaRegistration.AreaName + "/{controller}/{action}",
                defaults: new { area = areaRegistration.AreaName },
                namespaces: new[] { string.Format("{0}.Web.Areas.{1}.Controllers", defaultProjectPrefix, areaRegistration.AreaName) }
                );
        }
Ejemplo n.º 3
0
        public MvcRegistry()
        {
            var projectPrefix = MyProjectHelper.Resolve().GetProjectPrefix();

            Scan(
                scan =>
            {
                //assemblies
                scan.AssembliesFromApplicationBaseDirectory(assembly =>
                {
                    var name = assembly.GetName().Name;
                    return(name.StartsWith(projectPrefix) || name.StartsWith("CommonFx"));;
                });

                //scan.TheCallingAssembly();
                scan.WithDefaultConventions();
                scan.With(new ControllerConvention());
            });
        }
Ejemplo n.º 4
0
 public static void PreStart()
 {
     LogHelper.Log("PreStart: " + MyProjectHelper.Resolve().GetProjectPrefix());
 }