Exemple #1
0
        private static void xmlReadListOfObjects(object ParentObj, XmlReader xdr, IObservableList observableList)
        {
            // read list of object into the list, add one by one, like activities, actions etc.

            //TODO: Think/check if we want to make all observ as lazy load
            if (LazyLoadAttr.Contains(xdr.Name))
            // if (FastLoad) // && xdr.Name == nameof(BusinessFlow.Activities) || xdr.Name != nameof(Activity.Acts))
            {
                // We can save line/col and reload later when needed

                string s = xdr.ReadOuterXml(); // .ReadInnerXml(); // .Read();
                observableList.DoLazyLoadItem(s);

                return;
            }

            if (observableList.GetType() == typeof(ObservableList <RepositoryItemKey>))
            {
                xdr.Read();
                while (xdr.NodeType != XmlNodeType.EndElement)
                {
                    string RIKey = xdr.ReadElementContentAsString();

                    if (RIKey != null)
                    {
                        RepositoryItemKey repositoryItemKey = new RepositoryItemKey();
                        repositoryItemKey.Key = RIKey;
                        observableList.Add(repositoryItemKey);
                    }
                    else
                    {
                        return;
                    }
                }
                xdr.ReadEndElement();
            }
            else
            {
                xdr.Read();
                while (xdr.NodeType != XmlNodeType.EndElement)
                {
                    object item = xmlReadObject(ParentObj, xdr);
                    if (item != null)
                    {
                        observableList.Add(item);
                    }
                    else
                    {
                        return;
                    }
                }
                xdr.ReadEndElement();
            }
        }