Ejemplo n.º 1
0
        private static bool UpdateAndSerializerIndex(IObjectRepositoryIndex index, ObjectRepositoryChangeCollection changes, IObjectRepositorySerializer serializer, StringBuilder buffer, bool fullScan)
        {
            buffer.Clear();
            var binding      = index.DataAccessor.ConstructorParameterBinding;
            var updatedIndex = fullScan ? index.FullScan() : index.Update(changes);

            if (updatedIndex == null)
            {
                return(false);
            }

            var cloned = (IObjectRepositoryIndex)binding.Cloner(index,
                                                                (instance, propertyName, type, fallback) =>
                                                                propertyName == nameof(IObjectRepositoryIndex.Values) ? updatedIndex : fallback,
                                                                (childProperty, children, @new, dataAccessor) =>
                                                                throw new NotSupportedException("Index should not contain child properties."));

            serializer.Serialize(cloned, buffer);
            return(true);
        }
Ejemplo n.º 2
0
        private static void UpdateChangeTreeDefinitions(IRepository repository, IEnumerable <ObjectRepositoryEntryChanges> changes, TreeDefinition definition, IObjectRepositorySerializer serializer)
        {
            var buffer = new StringBuilder();

            foreach (var change in changes)
            {
                if (change.New is IObjectRepositoryIndex index)
                {
                    // Index are managed separately
                    continue;
                }
                buffer.Clear();
                var nested = serializer.Serialize(change.New, buffer);
                definition.Add(change.Path, repository.CreateBlob(buffer), Mode.NonExecutableFile);
                foreach (var info in nested)
                {
                    var nestedPath = change.New.GetDataPath(info.FileName);
                    definition.Add(nestedPath, repository.CreateBlob(info.Data), Mode.NonExecutableFile);
                }
            }
        }