protected override string?PropertyValidation(PropertyInfo pi) { if (pi.Name == nameof(EmbeddedInEntity)) { if (EmbeddedInEntity == null && EntityType != null) { return(ValidationMessage._0IsNecessary.NiceToString(pi.NiceName())); } if (EmbeddedInEntity != null && EntityType == null) { return(ValidationMessage._0IsNotAllowed.NiceToString(pi.NiceName())); } } if (pi.Name == nameof(CacheQueryConfiguration) && CacheQueryConfiguration != null && EntityType != null) { return(ValidationMessage._0ShouldBeNullWhen1IsSet.NiceToString(pi.NiceName(), NicePropertyName(() => EntityType))); } if (pi.Name == nameof(TokenEquivalencesGroups)) { var dups = TokenEquivalencesGroups .SelectMany(a => a.TokenEquivalences).Select(a => a.Token.Token).NotNull() .GroupCount(a => a).Where(gr => gr.Value > 1).ToString(a => a.Value + " x " + a.Key.FullKey(), "\n"); if (dups.HasText()) { return("Duplicated tokens: " + dups); } } return(base.PropertyValidation(pi)); }
public void FromXml(XElement element, IFromXmlContext ctx) { DisplayName = element.Attribute("DisplayName") !.Value; EntityType = element.Attribute("EntityType")?.Let(a => ctx.GetTypeLite(a.Value)); Owner = element.Attribute("Owner")?.Let(a => Lite.Parse <Entity>(a.Value)); HideDisplayName = element.Attribute("HideDisplayName")?.Let(a => bool.Parse(a.Value)) ?? false; DashboardPriority = element.Attribute("DashboardPriority")?.Let(a => int.Parse(a.Value)); EmbeddedInEntity = element.Attribute("EmbeddedInEntity")?.Let(a => a.Value.ToEnum <DashboardEmbedededInEntity>()); CombineSimilarRows = element.Attribute("CombineSimilarRows")?.Let(a => bool.Parse(a.Value)) ?? false; CacheQueryConfiguration = CacheQueryConfiguration.CreateOrAssignEmbedded(element.Element(nameof(CacheQueryConfiguration)), (cqc, elem) => cqc.FromXml(elem)); Parts.Synchronize(element.Element("Parts") !.Elements().ToList(), (pp, x) => pp.FromXml(x, ctx)); TokenEquivalencesGroups.Synchronize(element.Element(nameof(TokenEquivalencesGroups))?.Elements().ToList() ?? new List <XElement>(), (teg, x) => teg.FromXml(x, ctx)); ParseData(q => ctx.GetQueryDescription(q)); }
public XElement ToXml(IToXmlContext ctx) { return(new XElement("Dashboard", new XAttribute("Guid", Guid), new XAttribute("DisplayName", DisplayName), EntityType == null ? null ! : new XAttribute("EntityType", ctx.TypeToName(EntityType)), Owner == null ? null ! : new XAttribute("Owner", Owner.Key()), HideDisplayName == false ? null ! : new XAttribute("HideDisplayName", HideDisplayName.ToString()), DashboardPriority == null ? null ! : new XAttribute("DashboardPriority", DashboardPriority.Value.ToString()), EmbeddedInEntity == null ? null ! : new XAttribute("EmbeddedInEntity", EmbeddedInEntity.Value.ToString()), new XAttribute("CombineSimilarRows", CombineSimilarRows), CacheQueryConfiguration?.ToXml(ctx), new XElement("Parts", Parts.Select(p => p.ToXml(ctx))), new XElement(nameof(TokenEquivalencesGroups), TokenEquivalencesGroups.Select(teg => teg.ToXml(ctx))) )); }