Beispiel #1
0
        private bool shouldSort(StoreOptions options, out IComparer <IStorageOperation> comparer)
        {
            comparer = null;
            if (_operations.Count <= 1)
            {
                return(false);
            }

            if (_operations.Select(x => x.DocumentType).Distinct().Count() == 1)
            {
                return(false);
            }

            var types = _operations
                        .Select(x => x.DocumentType)
                        .Where(x => x != null)
                        .Distinct()
                        .TopologicalSort(type => options.Storage.GetTypeDependencies(type)).ToArray();

            if (_operations.OfType <IDeletion>().Any())
            {
                comparer = new StorageOperationWithDeletionsComparer(types);
            }
            else
            {
                comparer = new StorageOperationByTypeComparer(types);
            }

            return(true);
        }
Beispiel #2
0
        private bool shouldSort(List <IStorageOperation> operations, out IComparer <IStorageOperation> comparer)
        {
            comparer = null;
            if (operations.Count <= 1)
            {
                return(false);
            }

            if (operations.Select(x => x.DocumentType).Distinct().Count() == 1)
            {
                return(false);
            }

            var types = _operations.Value.Enumerate().Select(x => x.Key).TopologicalSort(GetTypeDependencies).ToArray();

            if (operations.OfType <IDeletion>().Any())
            {
                comparer = new StorageOperationWithDeletionsComparer(types);
            }
            else
            {
                comparer = new StorageOperationByTypeComparer(types);
            }

            return(true);
        }