private void AddNew() { const string defaultKeyName = "New Key"; var keyName = defaultKeyName; if (DataValues.Any(k => k.RawKey == keyName)) { var existingSameKey = DataValues.Where(k => k.RawKey.StartsWith(defaultKeyName)) .Select(k => k.RawKey.Replace(defaultKeyName, String.Empty)).Select( k => { if (int.TryParse(k, out var value)) { return(value); } return(0); } ).Max() + 1; keyName = defaultKeyName + existingSameKey.ToString(); } DataValues.Add(new EncryptedKeyPair(Algorithm) { RawKey = keyName, RawValue = "New Value" }); }
public void AddDataValue(DataValue dv) { if (DataValues.Any(x => x == dv)) { throw new ArgumentException("Duplicate Value."); } ((List <DataValue>)DataValues).Add(dv); }
public object this[string Name] { set { if (DataValues.Any(x => x.Name == Name)) { DataValues.First(x => x.Name == Name).Value = value; } } get { if (DataValues.Any(x => x.Name == Name)) { object v = DataValues.First(x => x.Name == Name).Value; return(v); } else { return(new object()); } } }