startup function

void startup(
  1. InjectionInitializer initializer,
  2. {List<String> activeProfiles,
  3. Map<String, InjectionInitializer> profileInitializers}
)

This function must be called at the very beginning of the application to initialize the injection context. The initializer is the one for the gloabl profile. The activeProfiles is a list of all the profile names that are currently activated. When resolving a service, the global profile and the all the activated profiles are used to search a service, where the global propfile has the least priority. The map profileInitializers are the initializers for the differemt know profiles.

Implementation

void startup(InjectionInitializer initializer,
    {List<String> activeProfiles, Map<String, InjectionInitializer> profileInitializers}) {
  _ContextCollection.shared.activeProfiles.addAll(activeProfiles ?? []);
  _ContextCollection.shared.activeProfiles.add(_ContextCollection.globalProfile);

  var globalContext = _ContextCollection.shared.globalContext;
  globalContext.startup(initializer);

  if (profileInitializers != null) {
    profileInitializers.keys.toList().forEach((profile) {
      _ContextCollection.shared.startupContext(profile, profileInitializers[profile]);
    });
  }
}