PropertiesI constructor

PropertiesI(
  1. StringSeq args, [
  2. Properties? defaults
])

Implementation

PropertiesI(StringSeq args, [Properties? defaults]) : _properties = {} {
  if (defaults != null) {
    final other = defaults as PropertiesI;
    // just copy, diff from cpp impliments;
    other._properties.forEach((key, value) {
      _properties[key] = value;
    });

    String p = getProperty('Ice.ProgramName');
    if (p.isEmpty) {
      if (args.isNotEmpty) {
        //
        // Use the first argument as the value for Ice.ProgramName. Replace
        // any backslashes in this value with forward slashes, in case this
        // value is used by the event logger.
        final name = args[0].replaceAll('\\', '/');
        _properties['Ice.ProgramName'] = _PropertyValue(name, true);
      }
    } else {
      _properties['Ice.ProgramName']!.used = true;
    }
  }

  final tmp = <String>[];

  bool loadConfigFiles = false;
  args.forEach((s) {
    if (s.startsWith('--Ice.Config')) {
      if (!s.contains('=')) {
        s += '=1';
      }
      _parseLine(s.substring(2));
      loadConfigFiles = true;
    } else {
      tmp.add(s);
    }
  });

  args = tmp;

  if (!loadConfigFiles) {
    // If Ice.Config is not set, load from ICE_CONFIG (if set)
    loadConfigFiles = !_properties.containsKey('Ice.Config');
  }

  if (loadConfigFiles) _loadConfig();

  parseIceCommandLineOptions(args);
}