Exemplo n.º 1
0
        private static ContentValidator GetValidator(this ContentOperation operation, bool optimize, bool published)
        {
            var validationContext =
                new ValidationContext(operation.Resolve <IJsonSerializer>(),
                                      operation.App.NamedId(),
                                      operation.Schema.NamedId(),
                                      operation.SchemaDef,
                                      operation.Components,
                                      operation.CommandId)
                .Optimized(optimize).AsPublishing(published);

            var validator =
                new ContentValidator(operation.Partition(),
                                     validationContext,
                                     operation.Resolve <IEnumerable <IValidatorsFactory> >(),
                                     operation.Resolve <ILogger <ContentValidator> >());

            return(validator);
        }
Exemplo n.º 2
0
        public static async Task CheckReferrersAsync(this ContentOperation operation)
        {
            var contentRepository = operation.Resolve <IContentRepository>();

            var hasReferrer = await contentRepository.HasReferrersAsync(operation.App.Id, operation.CommandId, SearchScope.All, default);

            if (hasReferrer)
            {
                throw new DomainException(T.Get("contents.referenced"), "OBJECT_REFERENCED");
            }
        }
 private static async Task ExecuteAsync(ContentOperation operation, string script, ScriptVars vars)
 {
     await operation.Resolve <IScriptEngine>().ExecuteAsync(vars, script, Options);
 }
Exemplo n.º 4
0
 private static IContentWorkflow GetWorkflow(ContentOperation operation)
 {
     return(operation.Resolve <IContentWorkflow>());
 }
 private static async Task <ContentData> TransformAsync(ContentOperation operation, string script, ScriptVars vars)
 {
     return(await operation.Resolve <IScriptEngine>().TransformAsync(vars, script, Options));
 }