public static void RegisterInstance(Type service, string key, object instance) { if (m_container != null) { m_container.RegisterInstance(service, key, instance); } }
public override void Configure(IChromelyContainer container) { base.Configure(container); container.RegisterInstance(typeof(IEventFactory), nameof(IEventFactory), new EventFactory()); container.RegisterSingleton( typeof(ChromelyController), nameof(ConfigurationController), typeof(ConfigurationController)); }
public static void RegisterCommnandRoutes(IChromelyContainer container, Dictionary <string, CommandRoute> newCommandDictionary) { if (newCommandDictionary != null && newCommandDictionary.Any()) { foreach (var item in newCommandDictionary) { container.RegisterInstance(typeof(CommandRoute), item.Key, item.Value); } } }
private void RegisterEventHandler <TEventArgs>( IChromelyContainer container, CefEventKey key, Action <object, TEventArgs, IChromelyContainer> handler) { var service = CefEventHandlerTypes.GetHandlerType(key); var eventHandler = new ChromelyEventHandler <TEventArgs>(key, (s, e) => handler(s, e, container)); container.RegisterInstance(service, eventHandler.Key, eventHandler); }
public virtual void Initialize(IChromelyContainer container, IChromelyConfiguration config, IChromelyLogger chromelyLogger) { EnsureExpectedWorkingDirectory(); if (config == null) { var configurator = new ConfigurationHandler(); config = configurator.Parse <DefaultConfiguration>(); } if (config == null) { config = new DefaultConfiguration(); } InitConfiguration(config); if (chromelyLogger == null) { chromelyLogger = new SimpleLogger(); } var defaultLogger = new DefaultLogger(); defaultLogger.Log = chromelyLogger; Logger.Instance = defaultLogger; config.Platform = ChromelyRuntime.Platform; _container = container; if (_container == null) { _container = new SimpleContainer(); } // Register all primary objects _container.RegisterInstance(typeof(IChromelyContainer), typeof(IChromelyContainer).Name, _container); _container.RegisterInstance(typeof(IChromelyConfiguration), typeof(IChromelyConfiguration).Name, config); _container.RegisterInstance(typeof(IChromelyLogger), typeof(IChromelyLogger).Name, chromelyLogger); }
public virtual void Initialize(IChromelyContainer container, IChromelyAppSettings appSettings, IChromelyConfiguration config, IChromelyLogger chromelyLogger) { EnsureExpectedWorkingDirectory(); #region Container _container = container; if (_container == null) { _container = new SimpleContainer(); } #endregion #region Configuration if (config == null) { var configurator = new ConfigurationHandler(); config = configurator.Parse <DefaultConfiguration>(); } if (config == null) { config = DefaultConfiguration.CreateForRuntimePlatform(); } InitConfiguration(config); config.Platform = ChromelyRuntime.Platform; #endregion #region Application/User Settings if (appSettings == null) { appSettings = new DefaultAppSettings(config.AppName); } var currentAppSettings = new CurrentAppSettings(); currentAppSettings.Properties = appSettings; ChromelyAppUser.App = currentAppSettings; ChromelyAppUser.App.Properties.Read(config); #endregion #region Logger if (chromelyLogger == null) { chromelyLogger = new SimpleLogger(); } var defaultLogger = new DefaultLogger(); defaultLogger.Log = chromelyLogger; Logger.Instance = defaultLogger; #endregion // Register all primary objects _container.RegisterInstance(typeof(IChromelyContainer), typeof(IChromelyContainer).Name, _container); _container.RegisterInstance(typeof(IChromelyAppSettings), typeof(IChromelyAppSettings).Name, appSettings); _container.RegisterInstance(typeof(IChromelyConfiguration), typeof(IChromelyConfiguration).Name, config); _container.RegisterInstance(typeof(IChromelyLogger), typeof(IChromelyLogger).Name, chromelyLogger); }
public static void RegisterCommandRoute(IChromelyContainer container, string key, CommandRoute command) { container.RegisterInstance(typeof(CommandRoute), key, command); }
public static void RegisterActionRoute(IChromelyContainer container, string key, ActionRoute route) { container.RegisterInstance(typeof(ActionRoute), key, route); }
private void RegisterEventHandler <T>(IChromelyContainer container, CefEventKey key, ChromelyEventHandler <T> handler) { var service = CefEventHandlerTypes.GetHandlerType(key); container.RegisterInstance(service, handler.Key, handler); }