Example #1
0
        public Generator()
        {
            Logger.CatchAll();
            Logger.Trace($"KY Generator v{Assembly.GetCallingAssembly().GetName().Version}");
            Logger.Trace("Current Directory: " + Environment.CurrentDirectory);
            Logger.Trace("Log Directory: " + Logger.File.Path);

            NugetPackageDependencyLoader.Activate();

            this.output   = new FileOutput(AppDomain.CurrentDomain.BaseDirectory);
            this.resolver = new DependencyResolver();
            this.resolver.Bind <ITypeMapping>().ToSingleton <TypeMapping>();
            this.resolver.Bind <CommandRunner>().ToSelf();
            this.resolver.Bind <ModuleFinder>().ToSelf();
            this.resolver.Bind <IConfigurationReaderVersion>().To <ConfigurationReaderVersion2>();
            this.resolver.Bind <ReaderConfigurationMapping>().ToSingleton();
            this.resolver.Bind <WriterConfigurationMapping>().ToSingleton();
            this.resolver.Bind <ConfigurationRunner>().ToSelf();
            this.resolver.Bind <ModelWriter>().ToSelf();
            StaticResolver.Resolver = this.resolver;

            ModuleFinder moduleFinder = this.resolver.Get <ModuleFinder>();

            moduleFinder.LoadFromAssemblies();
            this.Modules = moduleFinder.Modules;
            foreach (ModuleBase module in this.Modules)
            {
                Logger.Trace($"{module.GetType().Name.Replace("Module", "")}-{module.GetType().Assembly.GetName().Version} module loaded");
            }
            this.Modules.ForEach(module => this.resolver.Bind <ModuleBase>().To(module));
            this.Modules.ForEach(module => module.Initialize());
        }
Example #2
0
        public void Should_determine_correct_module_for_facade()
        {
            // Arrange
            var moduleFinder = new ModuleFinder();

            var container = BootContainer();


            // Act
            var finderResult = moduleFinder.FindModules(GetType().Assembly, container);

            // Assert
            finderResult.ShouldNotBeNull();
            finderResult.Modules.ShouldNotBeNull();
            finderResult.Modules.Length.ShouldBe(2);
            var moduleA = finderResult.Modules.First(x => x.Name.Equals("ModuleA"));

            moduleA.Name.ShouldBe("ModuleA");
            moduleA.Namespace.ShouldBe("Modularizr.Tests.ExampleApp.ModuleA");

            moduleA.PublicEntryServices.ShouldNotBeNull();
            moduleA.PublicEntryServices.Length.ShouldBe(2);
            moduleA.PublicEntryServices[0].Name.ShouldBe("IFacadeA");
            moduleA.PublicEntryServices[1].Name.ShouldBe("IFacadeAB");
        }
Example #3
0
        public async Task <ActionResult> EditModuleSettings(Guid pageVersionId, string position, object model)
        {
            var pageVersion = await pageService.GetPageVersionAsync(pageVersionId);

            var md = pageVersion.GetModule(position);
            await pageService.UpdateAsync(pageVersion);

            return(await ModuleFinder.Find(md.Type)?.Save(pageVersionId, position, Request.Form));
        }
Example #4
0
        public static void Register(this IServiceCollection services,
                                    IConfiguration configuration, IWebHostEnvironment env)
        {
            FrameworkCore.Register(services, configuration);
            ModelRegister.Register(services);
            BusinessRegister.Register(services);
            MessageServiceRegister.Register(services, configuration);
            LoggerRegister.Register(services);

            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <StaticResources>();
            services.AddSingleton <SessionManager>();
            services.AddSingleton <CookiesManager>();
            services.AddSingleton <IWebEnvironment, WebHost>();
            services.AddTransient <ILanguageLocalization, LanguageLocalization>();
            services.AddTransient <ViewRender>();
            services.AddSingleton <IAccountContext, AccountContext>();
            services.AddDistributedMemoryCache();
            services.AddSession();
            services.AddMemoryCache();
            services.AddResponseCompression();

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            var mvcBuilder = services.AddControllersWithViews(options =>
            {
                options.Filters.Add(typeof(GlobalFilter));
                // options.Filters.Add(typeof(ExceptionFilter));
            }).AddRazorRuntimeCompilation();


            mvcBuilder.AddSessionStateTempDataProvider();

            ModuleFinder moduleFinder = new ModuleFinder(env);
            var          modules      = moduleFinder.Find();

            if (modules.Any())
            {
                foreach (var module in modules)
                {
                    // Register controller from modules
                    mvcBuilder.AddApplicationPart(module.Assembly);
                }

                //Register module view location
                services.Configure <RazorViewEngineOptions>(options =>
                {
                    options.ViewLocationExpanders.Add(new ModuleViewLocationExpander());
                });
            }
            FrameworkCore.ServiceProvider = services.BuildServiceProvider();
        }
Example #5
0
 protected void Application_Start()
 {
     HostingEnvironment.RegisterVirtualPathProvider(DbPathProviderSingleton.Instance);
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     AutoMapperConfig.ConfigureMappings();
     UnityConfig.RegisterComponents();
     ModuleFinder.Init();
 }
Example #6
0
        public async Task <ActionResult> EditModuleType(Guid pageVersionId, string position)
        {
            var pageVersion = await pageService.GetPageVersionAsync(pageVersionId);

            var model = new EditModuleModel
            {
                Modules        = ModuleFinder.GetAllModules(),
                selectedModule = pageVersion.GetModule(position).Type
            };

            return(PartialView(model));
        }
        public void FindAsNodeModule()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\App\node_modules\MyModule\index.js", new MockFileData("exports.default = ()=>'Hello';") },
                { @"c:\App\font.ttf", new MockFileData("ttffilehere") }
            });
            var finder     = new ModuleFinder(fileSystem, new[] { "js" });
            var modulePath = finder.FindModulePath("MyModule", @"c:\App", null);

            Assert.AreEqual(@"c:\App\node_modules\MyModule\index.js", modulePath);
        }
Example #8
0
        public ActionResult RenderModule(Guid pageVersionId, string position)
        {
            var pageVersion = pageService.GetPageVersion(pageVersionId);
            var moduledata  = pageVersion.ModuleData.FirstOrDefault(md => md.Position == position);

            if (moduledata != null)
            {
                var isEditor = Request.IsAjaxRequest();
                return(ModuleFinder.Find(moduledata.Type)?.Index(pageVersionId, position, isEditor));
            }

            return(Content(""));
        }
Example #9
0
        private static void Main(string[] args)
        {
            DependencyResolver resolver = new DependencyResolver();
            ModuleFinder       finder   = new ModuleFinder(resolver);

            // Load all assemblies with names like *.Module.dll or *.Modules.dll
            finder.LoadFrom(AppDomain.CurrentDomain.BaseDirectory);
            // If all modules are in the same assembly or all assemblies are referenced, you can use LoadFromAssemblies instead of LoadFrom
            //finder.LoadFromAssemblies();
            finder.Modules.ForEach(module => module.Initialize());

            Console.ReadLine();
        }
        public void FindAsPackageModule()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\App\MyModule\a.js", new MockFileData("exports.default = ()=>'Hello';") },
                { @"c:\App\MyModule\package.json", new MockFileData("{'name':'mypackae','scripts':[],'main':'a.js'}") },
                { @"c:\App\font.ttf", new MockFileData("ttffilehere") }
            });
            var finder     = new ModuleFinder(fileSystem, new[] { "js" });
            var modulePath = finder.FindModulePath("./MyModule", @"c:\App", null);

            Assert.AreEqual(@"c:\App\MyModule\a.js", modulePath);
        }
Example #11
0
        private void XSocketOnOnReceive(object sender, EventArgs eventArgs)
        {
            var bytes  = (ByteArrayArgs)eventArgs;
            var packet = Encoding.UTF8.GetString(bytes.ByteArray);

            if (packet.StartsWith("dialog"))
            {
                //TODO: fix
                //    Packet.Handler.DialogLookUp(packet);
            }
            else
            {
                var parsedCommand = new ByteParser(bytes.ByteArray);
                ModuleFinder.FindModule(this, parsedCommand.CMD_ID, bytes.ByteArray);
            }
        }
Example #12
0
        public void set_up()
        {
            // sick creating of dependency checker
            IEnumerable <ModuleInfo> outter = new List <ModuleInfo>();

            DependencyChecker.Setup(
                x =>
                x.CheckModules(It.IsAny <IEnumerable <ModuleInfo> >(),
                               It.IsAny <IEnumerable <ModuleInfo> >(),
                               out outter))
            .Returns(true);

            ModuleFinder
            .Setup(x => x.FindDirectoryForPackage(It.IsAny <string>(), It.IsAny <ModulePackage>()))
            .Returns <string, ModulePackage>((dict, package) => dict);
        }
 public GeneratorModuleLoader(IDependencyResolver resolver, ModuleFinder moduleFinder)
 {
     this.resolver     = resolver;
     this.moduleFinder = moduleFinder;
 }
Example #14
0
 public void set_up()
 {
     _moduleFinder = new ModuleFinder();
 }