Example #1
0
        public static void Main(string[] args)
        {
            string pathToContentRoot = string.Empty;

            BootstrapLogger.Log("Application starting");

            pathToContentRoot = Directory.GetCurrentDirectory();
            BootstrapLogger.Log($"Content root : {pathToContentRoot}");

            if (!Debugger.IsAttached && args.Contains("--console"))
            {
                BootstrapLogger.Log("Running as a service.");

                var assemblyPath = typeof(Program).GetTypeInfo().Assembly.Location;
                pathToContentRoot = Path.GetDirectoryName(assemblyPath);
                BootstrapLogger.Log($"Assembly path : {assemblyPath}");
                BootstrapLogger.Log($"Service content root : {pathToContentRoot}");

                WindowsServiceRunner.Run(pathToContentRoot);
            }
            else
            {
                BootstrapLogger.Log("Running as a non-service.");
                Host.BuildAndRunHost(pathToContentRoot, args);
            }
        }
        static App()
        {
            BootstrapLogger.SetRootGlobal();

            ExecutablePath = Assembly.GetExecutingAssembly().Location;
            RootContainer  = new SimpleContainer <PapercutUIModule>().Build();
        }
Example #3
0
        public CompositeAppBuilder(IServiceCollection serviceCollection, IConfiguration configuration)
        {
            _containerConfigs = new List <IContainerConfig>();

            ServiceCollection = serviceCollection ?? throw new ArgumentNullException(nameof(serviceCollection));
            Configuration     = configuration ?? throw new ArgumentNullException(nameof(configuration));
            BootstrapLogger   = new BootstrapLogger();
        }
        public void Application_End(object sender, EventArgs e)
        {
            BootstrapLogger.Debug("Begin Application_End");

            Stop();

            BootstrapLogger.Debug("End Application_End");
        }
Example #5
0
        static void Main(string[] args)
        {
            BootstrapLogger.SetRootGlobal();

            using (_container = new SimpleContainer <PapercutServiceModule>().Build())
            {
                HostFactory.Run(ConfigureHost);
            }
        }
Example #6
0
        public void Init(Container container)
        {
            BootstrapLogger.Debug("Start initializer");

            InitCore(container);
            InitSite(container);

            BootstrapLogger.Debug("End initializer");
        }
Example #7
0
 private void LogModuleDependencies(IPluginModule module, IEnumerable <PropertyInfo> moduleProps)
 {
     foreach (PropertyInfo moduleProp in moduleProps)
     {
         BootstrapLogger.Add(LogLevel.Trace,
                             "Module: {moduleName} Property: {propName}:  References Module: {refModuleName}",
                             module.GetType().FullName,
                             moduleProp.Name,
                             moduleProp.PropertyType.FullName);
     }
 }
        public static void Start()
        {
            BootstrapLogger.Debug("Start initializer");

            Init();

            Schedule.Scheduler scheduler = container.GetInstance <Schedule.Scheduler>();
            scheduler.Start(10);

            BootstrapLogger.Debug("End initializer");
        }
Example #9
0
        //--------------------------------------------------
        //--Container Composition
        //--------------------------------------------------

        // Core plugins are composed from all other plugin types since they implement
        // reusable cross-cutting concerns.
        private void ComposeCorePlugins(ITypeResolver typeResolver)
        {
            BootstrapLogger.Add(LogLevel.Debug,
                                "Settings Plugin Module Properties Referencing Concrete Implementations.");

            var allPluginTypes = GetPluginTypes().ToArray();

            foreach (var plugin in CorePlugins)
            {
                typeResolver.ComposePlugin(plugin, allPluginTypes);
            }
        }
Example #10
0
        private void InitCore(Container container)
        {
            BootstrapLogger.Debug("Start Init Core");

            RegisterDatabase(container);
            RegisterParamsInConfig(container);
            RegisterCache(container);
            RegisterCacheInterceptor(container);
            RegisterInterceptor(container);

            BootstrapLogger.Debug("End Init Core");
        }
        public static void Stop()
        {
            BootstrapLogger.Debug("Stop Scheduler");

            Schedule.Scheduler scheduler = container.GetInstance <Schedule.Scheduler>();
            scheduler.Stop();

            BootstrapLogger.Debug("Stop Local Cache");

            StopLocalCache();

            BootstrapLogger.Debug("Dispose Container");

            container.Dispose();
        }
Example #12
0
        private void LogPlugins(IEnumerable <IPlugin> plugins)
        {
            foreach (var plugin in plugins.OrderBy(p => p.PluginType))
            {
                var details = new
                {
                    plugin.Name,
                    plugin.PluginId,
                    plugin.AssemblyName,
                    Configs = plugin.Configs.Select(c => c.GetType().FullName),
                    Modules = plugin.Modules.Select(m => m.GetType().FullName)
                };

                BootstrapLogger.Add(LogLevel.Debug, details.ToIndentedJson());
            }
        }
Example #13
0
        //---------------------------------------------
        //--Module Dependencies
        //---------------------------------------------

        // A plugin module can reference another module by referencing any of its supported interfaces
        // deriving from IPluginModuleService.  Finds all IPluginModuleService derived properties of the
        // referencing module and set them corresponding referenced module instance.
        private void ComposeModuleDependencies()
        {
            BootstrapLogger.Add(LogLevel.Debug,
                                "Settings Plugin Module Properties Referencing other Plugin Modules.");

            foreach (IPluginModule module in AllModules)
            {
                var dependentServiceProps = GetDependentServiceProperties(module);
                foreach (PropertyInfo serviceProp in dependentServiceProps)
                {
                    IPluginModuleService dependentService = GetModuleSupportingService(serviceProp.PropertyType);
                    serviceProp.SetValue(module, dependentService);
                }

                LogModuleDependencies(module, dependentServiceProps);
            }
        }
        static void Main(string[] args)
        {
            var log = new BootstrapLogger();

#if DEBUG
            log.UpdateLevel(LogLevel.Trace);
#else
            log.UpdateLevel(LogLevel.Info);
#endif
            log.Info("Loading Project Limitless...");

            log.Debug("Loading configuration...");
            var configLoader = new ConfigLoader();
            var settings     = configLoader.Load();

            var limitless = new Limitless(settings, log);
            limitless.Run();

            log.Info("Project Limitless has shut down.");
        }
 private static void StopLocalCache()
 {
     try
     {
         if (container != null)
         {
             LocalCacheHelper localCache = container.GetInstance <ICacheHelper>(CacheContainerKey.Local_Cache) as LocalCacheHelper;
             if (localCache != null)
             {
                 BootstrapLogger.Debug("Begin Stop Local Cache");
                 localCache.Stop();
                 BootstrapLogger.Debug("End Stop Local Cache");
             }
         }
     }
     catch (Exception ignore)
     {
         BootstrapLogger.Error(ignore.Message, ignore);
     }
 }