/// <summary> /// Remove a relationship between two objects. This will remove the keys for each side of the relationship. /// </summary> /// <typeparam name="T">The type of the sorce object</typeparam> /// <typeparam name="U">The type of the related object</typeparam> /// <param name="store">The underlying store</param> /// <param name="keyT">The key of the source object</param> /// <param name="keyU">The key of the related object</param> /// <param name="transformer"></param> public static void RemoveRelationship <T, U>(this IKVStore store, Key keyT, Key keyU, ITypeStringTransformer transformer = null) { var tr = transformer ?? new ForeignKeyTypeStringTransformer(); store.RemoveFromCollection(tr.TransformFor <T, U>(keyT), keyU.Value); store.RemoveFromCollection(tr.TransformFor <U, T>(keyU), keyT.Value); }
public Key GenerateKey(IKVStore store) { var sequenceValue = store.GetNextSequenceValue(string.Format("{0}:i", ConceptualTableKeyPrefix)); //todo : replace with customisable logic return(string.Format("{0}:{1}", ConceptualTableKeyPrefix, sequenceValue.ToString())); }
public Queue(IKVStore store, string key) { _store = store; _key = key; _idxStartKey = key + ":" + "iA"; _idxEndKey = key + ":" + "iB"; }
public KvLoginProvider(IKVStore store, string namespacePrefix = "ULP:", IRandomCharacterGenerator characterGen = null, IHasher hasher = null, IStringVerifier usernameVerifier = null, IStringVerifier passwordVerifier = null) { _store = new KeyTransformKVStore(store, new PrefixTransformer(namespacePrefix)); _usernameVerifier = usernameVerifier ?? new NullStringVerifier(); _passwordVerifier = passwordVerifier ?? new NullStringVerifier(); _characterGen = characterGen ?? new SimpleRandomCharacterGenerator(); _hasher = hasher ?? new Md5HasherWithSalt(); }
/// <summary> /// Retrieves all objects of type U and their retrospective keys whence given the key for type T /// </summary> /// <typeparam name="T">The type of the sorce object</typeparam> /// <typeparam name="U">The type of the related object</typeparam> /// <param name="store">The underlying store</param> /// <param name="keyT">The key of the source object</param> /// <param name="transformer"></param> /// <returns></returns> public static IEnumerable <KeyValuePair <string, U> > GetRelatedFor <T, U>(this IKVStore store, Key keyT, ITypeStringTransformer transformer = null) { var tr = transformer ?? new ForeignKeyTypeStringTransformer(); var keys = store.GetRelatedKeysFor <T, U>(keyT); return(keys.Select(key => new KeyValuePair <string, U>(key, store.Get <U>(key)))); }
public KeyWithRelationship GetRelationshipFor <T>(IKVStore store, Key key) { string relationshipSuffix; if (_foreignTypeAliases.TryGetValue(typeof(T), out relationshipSuffix)) { return(new KeyWithRelationship(key, new KVForeignKeyStoreRelationshipProvider(store, relationshipSuffix))); } return(null); }
public IEnumerable <KeyWithRelationship> BuildKeyRelationships <T>(IKVStore underlyingStore, Key key) { IObjectTypeSchema objectTypeSchema; if (!_schemaObjects.TryGetValue(typeof(T), out objectTypeSchema)) { throw new InvalidOperationException("No object schema available for " + typeof(T)); } return(objectTypeSchema.BuildKeyRelationships(underlyingStore, key)); }
public void Remove <T>(IKey foreignKey, IKVStore store, IStoreSchema schema) { IObjectTypeSchema thisObjectSchema = schema.GetObjectSchema <T>(); var relationships = thisObjectSchema.BuildKeyRelationships(store, Key); foreach (var relationship in relationships) { relationship.Remove(this); } }
/// <summary> /// Clears all relationships in both directtions between two types of objects connected to the source key. /// </summary> /// <typeparam name="T">The type of the sorce object</typeparam> /// <typeparam name="U">The type of the related object</typeparam> /// <param name="store">The underlying store</param> /// <param name="keyT">The key of the source object</param> /// <param name="transformer"></param> public static void ClearRelationships <T, U>(this IKVStore store, Key keyT, ITypeStringTransformer transformer = null) { var tr = transformer ?? new ForeignKeyTypeStringTransformer(); var keys = store.GetRelatedKeysFor <T, U>(keyT, tr); foreach (var keyU in keys) { store.RemoveRelationship <T, U>(keyT, keyU, tr); } }
public DualIndexStoreEnumerator(IKVStore store, string key) { _store = store; _key = key; string _idxStartKey = key + ":" + "iA"; string _idxEndKey = key + ":" + "iB"; _startIdx = GetSeqValue(_idxStartKey); _endIdx = GetSeqValue(_idxEndKey); _enumeratorIdx = _startIdx; }
public void TestInit() { var r = new ExtensionNode(); r.Key = "0a0c".HexToBytes(); var b = new BranchNode(); var l1 = new ExtensionNode(); l1.Key = new byte[] { 0x01 }; var l2 = new ExtensionNode(); l2.Key = new byte[] { 0x09 }; var v1 = new LeafNode(); v1.Value = "abcd".HexToBytes(); var v2 = new LeafNode(); v2.Value = "2222".HexToBytes(); var v3 = new LeafNode(); v3.Value = Encoding.ASCII.GetBytes("hello"); var h1 = new HashNode(); h1.Hash = v3.GetHash(); var l3 = new ExtensionNode(); l3.Next = h1; l3.Key = "0e".HexToBytes(); r.Next = b; b.Children[0] = l1; l1.Next = v1; b.Children[9] = l2; l2.Next = v2; b.Children[10] = l3; root = r; var store = new MemoryStore(); var db = new MPTDb(store); this.rootHash = root.GetHash(); db.Put(r); db.Put(b); db.Put(l1); db.Put(l2); db.Put(l3); db.Put(v1); db.Put(v2); db.Put(v3); this.mptdb = store; }
public IEnumerable <KeyWithRelationship> BuildKeyRelationships(IKVStore store, Key key) { return(_foreignTypeAliases.Select( s => new KeyWithRelationship(key, new KVForeignKeyStoreRelationshipProvider(store, s.Value)))); }
public static KVProfileProvider <StrDictProfile> GetStringDictProfile(IKVStore store) { return(new KVProfileProvider <StrDictProfile>(store)); }
public MPTDb(IKVStore store) : base(store) { this.store = store; }
public KVStoreTest(ITestOutputHelper output, ServiceFixture_MySql fixture) { _output = output; _kvStore = fixture.ServiceProvider.GetRequiredService <IKVStore>(); }
public MPTTrie(UInt256 root, IKVStore store) : base(root, store) { this.db = new MPTDb(store); }
public KeyTransformKVStore(IKVStore underlyingStore, IStringTransformer transformer = null) { _store = underlyingStore; _transformer = transformer ?? new NullStringTransformer(); }
public TypesafeKVStore(IKVStore underlyingStore, ITypeStringTransformer generator = null) : base(underlyingStore) { _generator = generator ?? new TypeStringTransformer(null); }
public LazySetKeyValueStore(IKVStore underlyingStore) { _store = underlyingStore; }
public UserLoginControlRepo(IKVStore kvStore) : base(kvStore) { }
public KVProfileProvider(IKVStore store, string namespacePrefix = "UPP:") { _store = new KeyTransformKVStore(store, new PrefixTransformer(namespacePrefix)); }
public KvRoleProvider(IKVStore store, string namespacePrefix = "URP:") { _store = new KeyTransformKVStore(store, new PrefixTransformer(namespacePrefix)); _usersToRolesFK = new KVForeignKeyStoreRelationshipProvider(_store, "Roles"); _rolesToUsersFK = new KVForeignKeyStoreRelationshipProvider(_store, "Users"); }
public KVRelationalStore(IKVStore store, IStoreSchema schema) { _store = store; _schema = schema; }
public LoggingKVStore(IKVStore underlyingStore, IKVLogger logger) { _store = underlyingStore; _logger = logger; }
protected KVStoreRepository(IKVStore kVStore) { KVStore = kVStore; }
/// <summary> /// Gets all the related keys to objects of type U connected to keyT. This can be used in either direction /// </summary> /// <typeparam name="T">The type of the sorce object</typeparam> /// <typeparam name="U">The type of the related object</typeparam> /// <param name="store">The underlying store</param> /// <param name="keyT">The key of the source object</param> /// <param name="transformer"></param> /// <returns></returns> public static IEnumerable <string> GetRelatedKeysFor <T, U>(this IKVStore store, Key keyT, ITypeStringTransformer transformer = null) { var tr = transformer ?? new ForeignKeyTypeStringTransformer(); return(store.GetCollection <string>(tr.TransformFor <T, U>(keyT)).Distinct()); }
/// <summary> /// Maintains a relationship of a key to a number of 'foreign key references' by creating an extra tracker key defined by itself and the suffix /// </summary> /// <param name="store">The underlying store to read to and write from</param> /// <param name="relationshipSuffixCollection">If there are more than 1 conceptual foreign key references, /// this can be used to isolate the target collection types, so links to multiple conceptual 'tables' are not confused</param> /// <param name="relationshipSuffix">This will be used as a suffix in the tracker key so it is uniquely identifiable back to the source key. Normally the default is sufficient</param> public KVForeignKeyStoreRelationshipProvider(IKVStore store, string relationshipSuffixCollection = null) { _store = new KeyTransformKVStore(store, new SuffixTransformer(relationshipSuffix + relationshipSuffixCollection)); }