Esempio n. 1
0
        public async Task AddReservedNamespaceAsync(ReservedNamespace newNamespace)
        {
            if (newNamespace == null)
            {
                throw new ArgumentNullException(nameof(newNamespace));
            }

            ValidateNamespace(newNamespace.Value);

            var matchingReservedNamespaces = FindAllReservedNamespacesForPrefix(prefix: newNamespace.Value, getExactMatches: !newNamespace.IsPrefix);

            if (matchingReservedNamespaces.Any())
            {
                throw new InvalidOperationException(Strings.ReservedNamespace_NamespaceNotAvailable);
            }

            // Mark the new namespace as shared if it matches any liberal namespace which is a shared
            // namespace. For eg: A.B.* is a shared namespace, when reserving A.B.C.* namespace,
            // make it a shared namespace. This ensures that all namespaces under a shared
            // namespace are also shared to keep the data consistent.
            if (!newNamespace.IsSharedNamespace && ShouldForceSharedNamespace(newNamespace.Value))
            {
                newNamespace.IsSharedNamespace = true;
            }

            ReservedNamespaceRepository.InsertOnCommit(newNamespace);
            await ReservedNamespaceRepository.CommitChangesAsync();
        }
Esempio n. 2
0
        public async Task AddReservedNamespaceAsync(ReservedNamespace newNamespace)
        {
            if (newNamespace == null)
            {
                throw new ArgumentNullException(nameof(newNamespace));
            }

            ValidateNamespace(newNamespace.Value);

            var matchingReservedNamespaces = FindAllReservedNamespacesForPrefix(prefix: newNamespace.Value, getExactMatches: !newNamespace.IsPrefix);

            if (matchingReservedNamespaces.Any())
            {
                throw new InvalidOperationException(Strings.ReservedNamespace_NamespaceNotAvailable);
            }

            ReservedNamespaceRepository.InsertOnCommit(newNamespace);
            await ReservedNamespaceRepository.CommitChangesAsync();
        }