Esempio n. 1
0
        public static void ReadFromXMLChildItemsByName <T>(XElement xml, string childColletionTagName, ICollection <T> childCollection, MobiseModel parent) where T : MobiseModel
        {
            XElement childColletionTag = xml.Element(childColletionTagName);

            if (childColletionTag != null && childColletionTag.HasElements)
            {
                // Parallel.ForEach(controls.Elements("control"), (element) =>
                foreach (XElement element in childColletionTag.Elements())
                {
                    string childItemName = element.Attribute("name") != null?element.Attribute("name").Value : string.Empty;

                    T newControl = childCollection.FirstOrDefault(ctrl => ctrl.Name == childItemName);
                    if (newControl == null)
                    {
                        newControl = System.Activator.CreateInstance(typeof(T), parent) as T;
                        childCollection.Add(newControl);
                    }
                    newControl.FromXml(element);
                }
                ;
            }
        }
Esempio n. 2
0
 public MobiseModel(MobiseModel parent)
     : this()
 {
     this.Parent = parent;
 }