コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnOK_Click(object sender, EventArgs e)
        {
            DeviceCollection cs = GetInOrOutDeviceCollection();

            cs.Clear();

            foreach (ListItem li in this.clStation.Items)
            {
                if (li.Selected)
                {
                    int         id     = Convert.ToInt32(li.Value);
                    DeviceClass device = DeviceFactory.CreateDevice(id);
                    cs.Add(device);
                }
            }
            Redirect();
        }
コード例 #2
0
        public static void LoadFromString(string xml, DeviceCollection devices)
        {
            if (xml == null)
            {
                throw new ArgumentNullException(nameof(xml));
            }
            if (devices == null)
            {
                throw new ArgumentNullException(nameof(devices));
            }

            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings()
            {
                IgnoreComments = true, IgnoreWhitespace = true
            };
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(JC2Data));

            using (XmlReader xmlReader = XmlReader.Create(new StringReader(xml), xmlReaderSettings)) {
                JC2Data jc2data = (JC2Data)xmlSerializer.Deserialize(xmlReader);

                devices.Clear();
                foreach (JC2DectDevice jc2dectDevice in jc2data.DectDevices)
                {
                    devices.Add(new DectDevice(jc2dectDevice));
                }
                foreach (JC2JuisDevice jc2juisDevice in jc2data.JuisDevices)
                {
                    devices.Add(new JuisDevice(jc2juisDevice));
                }

                devices.Settings.Reset();
                foreach (JC2Setting setting in jc2data.Settings)
                {
                    devices.Settings.Add(setting.Name, setting.Value);
                }
            }
        }