Exemplo n.º 1
0
            private static IPropertySet ReadProperties(XmlReader reader, string endElement)
            {
                var memento = new PropertySet();

                if (reader.IsEmptyElement)
                {
                    return(memento);
                }

                memento.BeginEdit();

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.EndElement:
                        if (reader.LocalName == endElement)
                        {
                            return(memento);
                        }
                        break;

                    case XmlNodeType.Element:
                        string propertyName = reader.LocalName;
                        if (propertyName == "Properties")
                        {
                            propertyName          = reader.GetAttribute(0);
                            memento[propertyName] = ReadProperties(reader, "Properties");
                        }
                        else if (propertyName == "Array")
                        {
                            propertyName          = reader.GetAttribute(0);
                            memento[propertyName] = ReadArray(reader);
                        }
                        else if (propertyName == "SerializedValue")
                        {
                            propertyName          = reader.GetAttribute(0);
                            memento[propertyName] = new ComponentModel.SerializedValue(reader.ReadInnerXml());
                        }
                        else
                        {
                            memento[propertyName] = reader.HasAttributes ? reader.GetAttribute(0) : null;
                        }
                        break;
                    }
                }

                memento.EndEdit();
                memento.AcceptChanges();
                return(memento);
            }