private Configs GetConfigFromAttributes()
{
// parse attributes to exclude
var excludeAttributes = GetAttribute(CONFIG_EXCLUDEATTRIBUTES)
.Split(valueSeparators, StringSplitOptions.RemoveEmptyEntries) // split list by valueSeparators
.Select(s => (s ?? string.Empty).Trim()) // convert null to "" and trim
.Where(s => s.Length > 0) // keep only non-empty strings
.ToArray();
// parse write period
int writePeriodMs = GetAttributeAsInt(CONFIG_WRITEPERIODMS, (int)defaultConfigs.WritePeriod.TotalMilliseconds);
writePeriodMs = Math.Max(writePeriodMs, minWritePeriodMs);
// construct configs from attributes
var configs = new Configs
{
AWSAccessKey = GetAttribute(CONFIG_ACCESSKEY),
AWSSecretKey = GetAttribute(CONFIG_SECRETKEY),
Region = RegionEndpoint.GetBySystemName(GetAttribute(CONFIG_REGION, defaultConfigs.Region.SystemName)),
TableName = GetAttribute(CONFIG_TABLE, defaultConfigs.TableName),
ReadUnits = GetAttributeAsInt(CONFIG_READ_UNITS, defaultConfigs.ReadUnits),
WriteUnits = GetAttributeAsInt(CONFIG_WRITE_UNITS, defaultConfigs.WriteUnits),
CreateTableIfNotExist = GetAttributeAsBool(CONFIG_CREATE_TABLE_IF_NOT_EXIST, defaultConfigs.CreateTableIfNotExist),
MaxLength = GetAttributeAsInt(CONFIG_MAXLENGTH, defaultConfigs.MaxLength),
HashKeyFormat = GetAttribute(CONFIG_HASHKEYFORMAT, defaultConfigs.HashKeyFormat),
RangeKeyFormat = GetAttribute(CONFIG_RANGEKEYFORMAT, defaultConfigs.RangeKeyFormat),
HashKey = GetAttribute(CONFIG_HASHKEY, defaultConfigs.HashKey),
RangeKey = GetAttribute(CONFIG_RANGEKEY, defaultConfigs.RangeKey),
WritePeriod = TimeSpan.FromMilliseconds(writePeriodMs),
ExcludeAttributes = excludeAttributes,
LogFilesDirectory = GetAttribute(CONFIG_LOGFILESDIR, defaultConfigs.LogFilesDirectory)
};
return configs;
}
private bool GetAttributeAsBool(string name, bool defaultValue = false)