private void loadDataForControlAndChildren( Control control ) { var controlTreeDataLoader = control as ControlTreeDataLoader; if( controlTreeDataLoader != null ) controlTreeDataLoader.LoadData(); foreach( var child in control.Controls.Cast<Control>().Where( i => i != etherealPlace ) ) loadDataForControlAndChildren( child ); List<EtherealControl> etherealControls; if( !etherealControlsByControl.TryGetValue( control, out etherealControls ) ) etherealControls = new List<EtherealControl>(); if( etherealControls.Any() ) { var np = new NamingPlaceholder( etherealControls.Select( i => { // This is kind of a hack, but it's an easy way to make sure ethereal controls are initially hidden. i.Control.Style.Add( HtmlTextWriterStyle.Display, "none" ); return i.Control; } ) ) { ID = "ethereal{0}".FormatWith( control.UniqueID.Replace( "$", "" ) ) }; etherealPlace.AddControlsReturnThis( np ); ( (ControlTreeDataLoader)np ).LoadData(); } foreach( var child in etherealControls ) loadDataForControlAndChildren( child.Control ); }
// Web Forms compatibility. Remove when EnduraCode goal 790 is complete. private static IReadOnlyCollection <Control> addEtherealControls(Control parent, EtherealComponentOrElement component) { var element = component as ElementNode; if (element != null) { EwfPage.Instance.AddEtherealControl(parent, element); return(((EtherealControl)element).Control.ToCollection()); } var etherealComponent = component as EtherealComponent; if (etherealComponent != null) { return(etherealComponent.GetChildren().AddEtherealControls(parent)); } var identifiedComponent = (IdentifiedEtherealComponent)component; var componentData = identifiedComponent.ComponentDataGetter(); Control ph = null; ph = new PlaceholderControl( () => { foreach (var linker in componentData.UpdateRegionLinkers) { EwfPage.Instance.AddUpdateRegionLinker( new LegacyUpdateRegionLinker( ph, linker.KeySuffix, linker.PreModificationRegions.Select( region => new LegacyPreModificationUpdateRegion( region.Sets, () => region.ComponentGetter().SelectMany(i => EwfPage.Instance.ControlsByComponent[i]), region.ArgumentGetter)), arg => linker.PostModificationRegionGetter(arg).SelectMany(i => EwfPage.Instance.ControlsByComponent[i]))); } var validationIndex = 0; var errorDictionary = new Dictionary <EwfValidation, IReadOnlyCollection <string> >(); foreach (var i in componentData.Validations) { errorDictionary.Add(i, EwfPage.Instance.AddModificationErrorDisplayAndGetErrors(ph, validationIndex.ToString(), i).ToImmutableArray()); validationIndex += 1; } var children = componentData.ChildGetter(new ModificationErrorDictionary(errorDictionary.ToImmutableDictionary())); if (componentData.Id == null) { children.AddEtherealControls(ph); return(ImmutableArray <Control> .Empty); } var np = new NamingPlaceholder(ImmutableArray <Control> .Empty); if (componentData.Id.Any()) { np.ID = componentData.Id + "np"; } children.AddEtherealControls(np); return(np.ToCollection()); }); if (!string.IsNullOrEmpty(componentData.Id)) { ph.ID = componentData.Id; } parent.AddControlsReturnThis(ph); return(ph.ToCollection()); }
// Web Forms compatibility. Remove when EnduraCode goal 790 is complete. private static IReadOnlyCollection <Control> addEtherealControls(Control parent, EtherealComponentOrElement component) { if (component is ElementNode element) { EwfPage.Instance.AddEtherealControl(parent, element); return(((EtherealControl)element).Control.ToCollection()); } if (component is EtherealComponent etherealComponent) { var controls = etherealComponent.GetChildren().AddEtherealControls(parent); if (component is EtherealAutofocusRegion autofocusRegion) { foreach (var i in controls) { if (!EwfPage.Instance.AutofocusConditionsByControl.TryGetValue(i, out var conditions)) { conditions = new List <AutofocusCondition>(); EwfPage.Instance.AutofocusConditionsByControl.Add(i, conditions); } conditions.Add(autofocusRegion.Condition); } } return(controls); } var identifiedComponent = (IdentifiedEtherealComponent)component; var componentData = identifiedComponent.ComponentDataGetter(); Control ph = null; ph = new PlaceholderControl( () => { foreach (var linker in componentData.UpdateRegionLinkers) { EwfPage.Instance.AddUpdateRegionLinker( new LegacyUpdateRegionLinker( ph, linker.KeySuffix, linker.PreModificationRegions.Select( region => new LegacyPreModificationUpdateRegion( region.Sets, () => region.ComponentGetter().SelectMany(i => EwfPage.Instance.ControlsByComponent[i]), region.ArgumentGetter)), arg => linker.PostModificationRegionGetter(arg).SelectMany(i => EwfPage.Instance.ControlsByComponent[i]))); } var validationIndex = 0; var errorDictionary = new Dictionary <EwfValidation, IReadOnlyCollection <string> >(); foreach (var i in componentData.ErrorSources.Validations) { var errors = EwfPage.Instance.AddModificationErrorDisplayAndGetErrors(ph, validationIndex.ToString(), i).ToImmutableArray(); errorDictionary.Add(i, errors); if (errors.Any()) { EwfPage.Instance.ValidationsWithErrors.Add(i); } validationIndex += 1; } var children = componentData.ChildGetter( new ModificationErrorDictionary( errorDictionary.ToImmutableDictionary(), componentData.ErrorSources.IncludeGeneralErrors ? AppRequestState.Instance.EwfPageRequestState.GeneralModificationErrors : ImmutableArray <TrustedHtmlString> .Empty)); if (componentData.Id == null) { children.AddEtherealControls(ph); return(ImmutableArray <Control> .Empty); } var np = new NamingPlaceholder(ImmutableArray <Control> .Empty); if (componentData.Id.Any()) { np.ID = componentData.Id + "np"; } children.AddEtherealControls(np); return(np.ToCollection()); }); if (!string.IsNullOrEmpty(componentData.Id)) { ph.ID = componentData.Id; } parent.AddControlsReturnThis(ph); return(ph.ToCollection()); }