Example #1
0
        bool TryUpdateObject(StateSnapshot snapshot, UpdatedKey updatedKey)
        {
            KeyRef key  = updatedKey.Key;
            Guid?  guid = ParseObjectKey(key);

            if (guid == null)
            {
                return(false);
            }
            SomeObject obj;

            if (!_objects.TryGetValue(guid.Value, out obj))
            {
                return(false);
            }

            foreach (ulong subkey in updatedKey.InsertedSubkeys)
            {
                obj.UpdateData(snapshot.TryGetValue(key, subkey));
            }

            foreach (ulong subkey in updatedKey.UpdatedSubkeys)
            {
                obj.UpdateData(snapshot.TryGetValue(key, subkey));
            }

            foreach (ulong subkey in updatedKey.RemovedSubkeys)
            {
                obj.UpdateData(new SubkeySnapshot());
            }

            return(true);
        }
Example #2
0
        Guid?ParseObjectKey(KeyRef key)
        {
            ReadOnlySpan <byte> keySpan = key.ToSpan();

            if (keySpan.Length == ObjectKeySize || keySpan[0] == ObjectKeyPrefix)
            {
                return(new Guid(keySpan.Slice(1)));
            }
            return(null);
        }
Example #3
0
        bool TryRemoveObject(KeyRef key)
        {
            Guid?guid = ParseObjectKey(key);

            return(guid.HasValue && _objects.Remove(guid.Value));
        }