public static Button ToButton(this ButtonConfig button, IEnumerable <EntityVariant>?entityVariants, EntityVariant baseEntityVariant) { return(button switch { DefaultButtonConfig defaultButton => defaultButton.ToDefaultButton(entityVariants, baseEntityVariant), CustomButtonConfig customButton => customButton.ToCustomButton(), PaneButtonConfig paneButton => paneButton.ToPaneButton(baseEntityVariant), _ => throw new InvalidOperationException() });
private void CreateButton(PageStyle pageStyle, bool isData) { var bts = ModuleConfig.Buttons.Where(a => a.Name == pageStyle.ToString()); bool isBt = bts != null && bts.Count() > 0; if (!isBt) { CustomButtonConfig bt = new CustomButtonConfig(); bt.IsData = isData; bt.Name = pageStyle.ToString(); bt.Text = pageStyle.GetDescription(); bt.Client = new ClientConfig() { Function = pageStyle.ToString() }; ModuleConfig.Buttons.Add(bt); } else { //Debug.AssertArgument(bts.Count() == 1, pageStyle.ToString(), string.Format(ObjectUtil.SysCulture, var bt = bts.FirstOrDefault(); if (!bt.IsData && isData) { bt.IsData = true; } if (bt.Text.IsEmpty()) { bt.Text = pageStyle.GetDescription(); } if (bt.Client == null) { bt.Client = new ClientConfig() { Function = pageStyle.ToString() }; } } // return bt; }