Deserialize() public method

public Deserialize ( System.Xml.Linq.XElement element ) : void
element System.Xml.Linq.XElement
return void
Beispiel #1
0
        public virtual void Deserialize(XElement element)
        {
            if (string.Compare(element.Name.ToString(), "devicefamily") == 0)
            {
                XAttribute nameAttr = element.Attribute("name");
                if (nameAttr != null)
                {
                    Name = nameAttr.Value;
                }
                nameAttr = element.Attribute("shortname");
                if (nameAttr != null)
                {
                    ShortName = nameAttr.Value;
                }

                XElement packages = element.Element("packages");
                foreach (XElement packageElement in packages.Elements())
                {
                    DevicePackage package = new DevicePackage(this);
                    package.Deserialize(packageElement);
                    Packages.Add(package);
                }

                XElement speeds = element.Element("speeds");
                foreach (XElement speedElement in speeds.Elements())
                {
                    DeviceSpeed speed = new DeviceSpeed(this);
                    speed.Deserialize(speedElement);
                    Speeds.Add(speed);
                }

                XElement devices = element.Element("devices");
                foreach (XElement deviceElement in devices.Elements())
                {
                    Device device = new Device(this);
                    device.Deserialize(deviceElement);
                    Devices.Add(device);
                }
            }
        }
        public virtual void Deserialize(XElement element)
        {
            if (string.Compare(element.Name.ToString(), "devicefamily") == 0)
            {
                XAttribute nameAttr = element.Attribute("name");
                if (nameAttr != null)
                {
                    Name = nameAttr.Value;
                }
                nameAttr = element.Attribute("shortname");
                if (nameAttr != null)
                {
                    ShortName = nameAttr.Value;
                }
                XAttribute typeAttr = element.Attribute("type");
                if (typeAttr != null)
                {
                    Type = (DeviceType)Enum.Parse(typeof(DeviceType), typeAttr.Value);
                }

                XElement packages = element.Element("packages");
                foreach (XElement packageElement in packages.Elements())
                {
                    DevicePackage package = new DevicePackage(this);
                    package.Deserialize(packageElement);
                    Packages.Add(package);
                }

                XElement speeds = element.Element("speeds");
                foreach (XElement speedElement in speeds.Elements())
                {
                    DeviceSpeed speed = new DeviceSpeed(this);
                    speed.Deserialize(speedElement);
                    Speeds.Add(speed);
                }

                XElement devices = element.Element("devices");
                foreach (XElement deviceElement in devices.Elements())
                {
                    Device device = new Device(this);
                    device.Deserialize(deviceElement);
                    Devices.Add(device);
                }
            }
        }