示例#1
0
 protected virtual void ClearParentEntity(ModifiableEntity p)
 {
     if (p == this.parentEntity)
     {
         this.parentEntity = null;
     }
 }
示例#2
0
        private void SetParentEntity(ModifiableEntity? p)
        {
            if (p != null && this.parentEntity != null && this.parentEntity != p)
                throw new InvalidOperationException($"'{nameof(parentEntity)}' is still connected to '{parentEntity}'");

            this.parentEntity = p;
        }
示例#3
0
        public void AssertCanWrite(PropertyRoute pr, ModifiableEntity?mod)
        {
            string?error = CanWritePropertyRoute.GetInvocationListTyped().Select(a => a(pr, mod)).NotNull().FirstOrDefault();

            if (error != null)
            {
                throw new UnauthorizedAccessException(error);
            }
        }
示例#4
0
        protected virtual void SetParentEntity(ModifiableEntity p)
        {
            if (p != null && this.parentEntity != null && this.parentEntity != p)
            {
                throw new InvalidOperationException($"'{nameof(parentEntity)}' of '{this}'({this.GetType().TypeName()}) is still connected to '{parentEntity}'({parentEntity.GetType().TypeName()}), then can not be set to '{p}'({p.GetType().TypeName()})");
            }

            this.parentEntity = p;
        }
示例#5
0
        protected virtual void SetParentEntity(ModifiableEntity p)
        {
            if (p != null && this.parentEntity != null && this.parentEntity != p)
            {
                throw new InvalidOperationException($"'{nameof(parentEntity)}' is still connected to '{parentEntity}'");
            }

            this.parentEntity = p;
        }
示例#6
0
        private static string?EntityJsonConverter_CanWritePropertyRoute(PropertyRoute arg, ModifiableEntity?mod)
        {
            var val = Validator.TryGetPropertyValidator(arg);

            if (val == null || mod == null)
            {
                return(null);
            }

            if (val.IsPropertyReadonly(mod))
            {
                return($"Property {arg} is readonly");
            }

            return(null);
        }
示例#7
0
        private static IEnumerable <EmailMessageEntity> CreateEmailMessage(EmailTemplateEntity template, ModifiableEntity?modifiableEntity, ref IEmailModel?model)
        {
            Entity?entity = null;

            if (template.Model != null)
            {
                if (model == null)
                {
                    model = EmailModelLogic.CreateModel(template.Model, modifiableEntity);
                }
                else if (template.Model.ToType() != model.GetType())
                {
                    throw new ArgumentException("model should be a {0} instead of {1}".FormatWith(template.Model.FullClassName, model.GetType().FullName));
                }
            }
            else
            {
                entity = modifiableEntity as Entity ?? throw new InvalidOperationException("Model should be an Entity");
            }

            using (template.DisableAuthorization ? ExecutionMode.Global() : null)
                return(new EmailMessageBuilder(template, entity, model).CreateEmailMessageInternal().ToList());
        }
示例#8
0
 public static IEnumerable <EmailMessageEntity> CreateEmailMessage(this EmailTemplateEntity template, ModifiableEntity?modifiableEntity = null, IEmailModel?model = null)
 {
     return(CreateEmailMessage(template, modifiableEntity, ref model));
 }
示例#9
0
        public static IEnumerable <EmailMessageEntity> CreateEmailMessage(this Lite <EmailTemplateEntity> liteTemplate, ModifiableEntity?modifiableEntity = null, IEmailModel?model = null)
        {
            EmailTemplateEntity template = EmailTemplatesLazy.Value.GetOrThrow(liteTemplate, "Email template {0} not in cache".FormatWith(liteTemplate));

            return(CreateEmailMessage(template, modifiableEntity, ref model));
        }
示例#10
0
 public static IEmailModel CreateModel(EmailModelEntity model, ModifiableEntity?entity)
 {
     return((IEmailModel)EmailModelLogic.GetEntityConstructor(model.ToType()).Invoke(new[] { entity }));
 }