public void FromXml(XElement element, IFromXmlContext ctx) { Guid = Guid.Parse(element.Attribute("Guid").Value); Name = element.Attribute("Name").Value; DisableAuthorization = element.Attribute("DisableAuthorization")?.Let(a => bool.Parse(a.Value)) ?? false; Query = ctx.GetQuery(element.Attribute("Query").Value); EditableMessage = bool.Parse(element.Attribute("EditableMessage").Value); Model = element.Attribute("Model")?.Let(at => ctx.GetEmailModel(at.Value)); SendDifferentMessages = bool.Parse(element.Attribute("SendDifferentMessages").Value); MasterTemplate = element.Attribute("MasterTemplate")?.Let(a => (Lite <EmailMasterTemplateEntity>)ctx.GetEntity(Guid.Parse(a.Value)).ToLite()); SendDifferentMessages = bool.Parse(element.Attribute("GroupResults").Value); Filters.Synchronize(element.Element("Filters")?.Elements().ToList(), (f, x) => f.FromXml(x, ctx)); Orders.Synchronize(element.Element("Orders")?.Elements().ToList(), (o, x) => o.FromXml(x, ctx)); IsBodyHtml = bool.Parse(element.Attribute("IsBodyHtml").Value); From = element.Element("From")?.Let(from => new EmailTemplateContactEmbedded { DisplayName = from.Attribute("DisplayName")?.Value, EmailAddress = from.Attribute("EmailAddress")?.Value, Token = from.Attribute("Token")?.Let(t => new QueryTokenEmbedded(t.Value)), }); Recipients = element.Element("Recipients").Elements("Recipient").Select(rep => new EmailTemplateRecipientEmbedded { DisplayName = rep.Attribute("DisplayName").Value, EmailAddress = rep.Attribute("EmailAddress").Value, Kind = rep.Attribute("Kind").Value.ToEnum <EmailRecipientKind>(), Token = rep.Attribute("Token")?.Let(a => new QueryTokenEmbedded(a.Value)) }).ToMList(); Messages = element.Element("Messages").Elements("Message").Select(elem => new EmailTemplateMessageEmbedded(ctx.GetCultureInfoEntity(elem.Attribute("CultureInfo").Value)) { Subject = elem.Attribute("Subject").Value, Text = elem.Value }).ToMList(); Applicable = element.Element("Applicable")?.Let(app => new TemplateApplicableEval { Script = app.Value }); ParseData(ctx.GetQueryDescription(Query)); }
public void FromXml(XElement element, IFromXmlContext ctx) { Guid = Guid.Parse(element.Attribute("Guid").Value); Name = element.Attribute("Name").Value; DisableAuthorization = element.Attribute("DisableAuthorization")?.Let(a => bool.Parse(a.Value)) ?? false; Query = ctx.GetQuery(element.Attribute("Query").Value); EditableMessage = bool.Parse(element.Attribute("EditableMessage").Value); Model = ctx.GetEmailModel(element.Attribute("SystemEmail").Value); SendDifferentMessages = bool.Parse(element.Attribute("SendDifferentMessages").Value); MasterTemplate = Lite.ParsePrimaryKey <EmailMasterTemplateEntity>(element.Attribute("MasterTemplate").Value); IsBodyHtml = bool.Parse(element.Attribute("IsBodyHtml").Value); From = element.Element("From")?.Let(from => new EmailTemplateContactEmbedded { DisplayName = from.Attribute("DisplayName").Value, EmailAddress = from.Attribute("EmailAddress").Value, Token = from.Attribute("Token")?.Let(t => new QueryTokenEmbedded(t.Value)), }); Recipients = element.Element("Recipients").Elements("Recipient").Select(rep => new EmailTemplateRecipientEmbedded { DisplayName = rep.Attribute("DisplayName").Value, EmailAddress = rep.Attribute("EmailAddress").Value, Kind = rep.Attribute("Kind").Value.ToEnum <EmailRecipientKind>(), Token = rep.Attribute("Token") != null ? new QueryTokenEmbedded(rep.Attribute("Token").Value) : null }).ToMList(); Messages = element.Element("Messages").Elements("Message").Select(elem => new EmailTemplateMessageEmbedded(ctx.GetCultureInfoEntity(elem.Attribute("CultureInfo").Value)) { Subject = elem.Attribute("Subject").Value, Text = elem.Value }).ToMList(); Applicable = element.Element("Applicable")?.Let(app => new TemplateApplicableEval { Script = app.Value }); ParseData(ctx.GetQueryDescription(Query)); }
public void FromXml(XElement element, IFromXmlContext ctx) { Guid = Guid.Parse(element.Attribute("Guid") !.Value); Name = element.Attribute("Name") !.Value; DisableAuthorization = element.Attribute("DisableAuthorization")?.Let(a => bool.Parse(a.Value)) ?? false; Query = ctx.GetQuery(element.Attribute("Query") !.Value); EditableMessage = bool.Parse(element.Attribute("EditableMessage") !.Value); Model = element.Attribute("Model")?.Let(at => ctx.GetEmailModel(at.Value)); MasterTemplate = element.Attribute("MasterTemplate")?.Let(a => (Lite <EmailMasterTemplateEntity>)ctx.GetEntity(Guid.Parse(a.Value)).ToLite()); GroupResults = bool.Parse(element.Attribute("GroupResults") !.Value); Filters.Synchronize(element.Element("Filters")?.Elements().ToList(), (f, x) => f.FromXml(x, ctx)); Orders.Synchronize(element.Element("Orders")?.Elements().ToList(), (o, x) => o.FromXml(x, ctx)); IsBodyHtml = bool.Parse(element.Attribute("IsBodyHtml") !.Value); From = element.Element("From")?.Let(from => new EmailTemplateFromEmbedded { DisplayName = from.Attribute("DisplayName")?.Value, EmailAddress = from.Attribute("EmailAddress")?.Value, Token = from.Attribute("Token")?.Let(t => new QueryTokenEmbedded(t.Value)), WhenMany = from.Attribute("WhenMany")?.Value.ToEnum <WhenManyFromBehaviour>() ?? WhenManyFromBehaviour.FistResult, WhenNone = from.Attribute("WhenNone")?.Value.ToEnum <WhenNoneFromBehaviour>() ?? WhenNoneFromBehaviour.NoMessage, }); Recipients = element.Element("Recipients") !.Elements("Recipient").Select(rep => new EmailTemplateRecipientEmbedded { DisplayName = rep.Attribute("DisplayName")?.Value, EmailAddress = rep.Attribute("EmailAddress")?.Value, Kind = rep.Attribute("Kind") !.Value.ToEnum <EmailRecipientKind>(), Token = rep.Attribute("Token")?.Let(a => new QueryTokenEmbedded(a.Value)), WhenMany = rep.Attribute("WhenMany")?.Value?.ToEnum <WhenManyRecipiensBehaviour>() ?? WhenManyRecipiensBehaviour.KeepOneMessageWithManyRecipients, WhenNone = rep.Attribute("WhenNone")?.Value?.ToEnum <WhenNoneRecipientsBehaviour>() ?? WhenNoneRecipientsBehaviour.ThrowException, }).ToMList();