protected virtual void ClearParentEntity(ModifiableEntity p) { if (p == this.parentEntity) { this.parentEntity = null; } }
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; }
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); } }
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; }
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; }
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); }
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()); }
public static IEnumerable <EmailMessageEntity> CreateEmailMessage(this EmailTemplateEntity template, ModifiableEntity?modifiableEntity = null, IEmailModel?model = null) { return(CreateEmailMessage(template, modifiableEntity, ref model)); }
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)); }
public static IEmailModel CreateModel(EmailModelEntity model, ModifiableEntity?entity) { return((IEmailModel)EmailModelLogic.GetEntityConstructor(model.ToType()).Invoke(new[] { entity })); }