protected void ReadFromXMLChildItems(XElement xml, string childColletionTagName, ICollection <UIControlInstanceModel> childCollection) { ScreenModel screen = null; if (!(this is ScreenModel)) { System.Diagnostics.Debug.Assert(this.ParentScreen != null, "Parent Screen can't be null"); screen = this.ParentScreen; } else { screen = this as ScreenModel; } System.Diagnostics.Debug.Assert(screen.ParentProject != null, "Parent project can't be null"); System.Diagnostics.Debug.Assert(screen.ParentProject.mobiseConfiguration != null, "Mobise configuration can't be null"); System.Diagnostics.Debug.Assert(screen.ParentProject.mobiseConfiguration.Controls != null, "Mobise configuration control definitions can't be null"); System.Diagnostics.Debug.Assert(screen.ParentProject.mobiseConfiguration.ControllerDefinitons != null, "Mobise configuration controller definitions can't be null"); XElement childColletionTag = xml.Element(childColletionTagName); if (childColletionTag != null && childColletionTag.HasElements) { // Parallel.ForEach(controls.Elements("control"), (element) => foreach (XElement element in childColletionTag.Elements()) { string childItemID = element.Attribute("mobiseID") != null?element.Attribute("mobiseID").Value : string.Empty; UIControlInstanceModel newControl = childCollection.FirstOrDefault(ctrl => ctrl.MobiseObjectID == childItemID); if (newControl == null) { string controlType = element.Attribute("type") != null?element.Attribute("type").Value : string.Empty; UIControlDefinitionModel definition = null; definition = screen.ParentProject.mobiseConfiguration.Controls.FirstOrDefault(def => def.Name.Equals(controlType, StringComparison.OrdinalIgnoreCase)); if (definition != null) { newControl = new UIControlInstanceModel(definition); if (this is ScreenModel) { newControl.ParentScreen = this as ScreenModel; } else { newControl.ParentScreen = this.ParentScreen; } childCollection.Add(newControl); } } newControl.FromXml(element); } ; } }
public UIControlInstanceModel(MobiseModel parent, ScreenModel parentScreen, UIControlDefinitionModel definition) : this(definition) { this.Parent = parent; this.ParentScreen = parentScreen; }