コード例 #1
0
        /// <summary>
        /// Sets the execution context for any queries or commands
        /// chained of this instance. Typically used to impersonate
        /// a user, elevate permissions or maintain context in nested
        /// query or command execution.
        /// </summary>
        /// <param name="executionContext">
        /// The execution context instance to use.
        /// </param>
        public static IContentRepository WithExecutionContext(this IContentRepository contentRepository, IExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            var extendedContentRepositry = contentRepository.AsExtendableContentRepository();
            var newRepository            = extendedContentRepositry.ServiceProvider.GetRequiredService <IContentRepositoryWithCustomExecutionContext>();

            newRepository.SetExecutionContext(executionContext);

            return(newRepository);
        }
コード例 #2
0
 /// <summary>
 /// Queries and commands relating to document assets.
 /// </summary>
 public static IContentRepositoryDocumentAssetRepository DocumentAssets(this IContentRepository contentRepository)
 {
     return(new ContentRepositoryDocumentAssetRepository(contentRepository.AsExtendableContentRepository()));
 }
コード例 #3
0
 /// <summary>
 /// PageDirectories represent a folder in the dynamic web page hierarchy.
 /// </summary>
 public static IContentRepositoryPageDirectoryRepository PageDirectories(this IContentRepository contentRepository)
 {
     return(new ContentRepositoryPageDirectoryRepository(contentRepository.AsExtendableContentRepository()));
 }
コード例 #4
0
 /// <summary>
 /// Queries and commands relating to users from the Cofoundry identity
 /// system. This includes users from both the Cofoundry admin user area
 /// and any custom user areas.
 /// </summary>
 public static IContentRepositoryUserRepository Users(this IContentRepository contentRepository)
 {
     return(new ContentRepositoryUserRepository(contentRepository.AsExtendableContentRepository()));
 }
コード例 #5
0
        /// <summary>
        /// Runs any queries or commands chained off this instance under
        /// the system user account which has no permission restrictions.
        /// This is useful when you need to perform an action that the currently
        /// logged in user does not have permission for, e.g. signing up a new
        /// user prior to login.
        /// </summary>
        public static IContentRepository WithElevatedPermissions(this IContentRepository contentRepository)
        {
            var extendedApi = contentRepository.AsExtendableContentRepository();

            return(extendedApi.ServiceProvider.GetRequiredService <IContentRepositoryWithElevatedPermissions>());
        }
コード例 #6
0
        /// <summary>
        /// Used to manage transactions for multiple domain commands.
        /// This abstraction is an enhanced version of
        /// System.Transaction.TransactionScope and works in the same way.
        /// </summary>
        public static IContentRepositoryTransactionManager Transactions(this IContentRepository contentRepository)
        {
            var extendedContentRepositry = contentRepository.AsExtendableContentRepository();

            return(extendedContentRepositry.ServiceProvider.GetRequiredService <IContentRepositoryTransactionManager>());
        }
コード例 #7
0
 /// <summary>
 /// Custom entities are a flexible system for developer defined
 /// data structures which can be fully managed in the admin panel
 /// with minimal configuration.
 /// </summary>
 public static IContentRepositoryCustomEntityRepository CustomEntities(this IContentRepository contentRepository)
 {
     return(new ContentRepositoryCustomEntityRepository(contentRepository.AsExtendableContentRepository()));
 }