ATMLCommonLibrary.controls.switching.SwitchControl.ControlsToData C# (CSharp) Method

ControlsToData() protected method

protected ControlsToData ( ) : void
return void
        protected override void ControlsToData()
        {
            if (_item == null)
                _item = new Switch();
            base.ControlsToData();
            if (((Switch)_item).Interface == null)
                ((Switch)_item).Interface = new Interface();
            if (((Switch)_item).Interface.Ports == null)
                ((Switch)_item).Interface.Ports = new List<Port>();
            ((Switch)_item).Interface.Ports.Clear();
            foreach (ListViewItem lvi in lvInterface.Items)
            {
                var port = lvi.Tag as Port;
                if (port is PhysicalInterfacePortsPort)
                {
                    var p = new Port
                    {
                        direction = port.direction,
                        directionSpecified = port.directionSpecified,
                        Extension = port.Extension,
                        name = port.name,
                        type = port.type,
                        typeSpecified = port.typeSpecified
                    };
                    port = p;
                }

                ((Switch)_item).Interface.Ports.Add(port);
            }

            List<SwitchRelaySetting> srsList =
                (from ListViewItem lvi in lvSwitchRelays.Items select lvi.Tag as SwitchRelaySetting).ToList();

            ((Switch)_item).Connections = srsList;
        }