public static void WriteXml(Config config,string PathFileName ) { System.Xml.Serialization.XmlSerializer sr = new XmlSerializer(typeof(Config)); using( System.IO.Stream stream=System.IO.File.Open(PathFileName, System.IO.FileMode.Create)) { sr.Serialize(stream, config ); } }
static App() { config = Config.ReadXml("config.xml"); CeraDevices.CoordinatorDevice[] devices = new CoordinatorDevice[config.Coordinators.Length]; for (int i = 0; i < config.Coordinators.Length; i++) devices[i] = new CoordinatorDevice(config.Coordinators[i].BaseUrl); devmgr = new DeviceManager(devices); }
private async void Button_Click_3(object sender, RoutedEventArgs e) { StreetLightInfo[] infos = await device.GetStreetLightListAsync(); Config config = new wpfPanel.Config(); config.Coordinators = new CoordinatorConfig[] { new CoordinatorConfig(){ ID=0, BaseUrl=this.BaseUrl} }; config.Groups = new GroupConfig[]{ new GroupConfig(){ GroupID=0, GroupName="ALL", DimLevel=0} }; // config.Groups[0].Devices = new DeviceConfig[infos.Length]; var q = from n in infos orderby n.RmkID select new DeviceConfig() { CoordinatorID = 0, RmkID = n.RmkID, MAC = n.MAC }; //for (int i = 0; i < infos.Length; i++) //{ config.Groups[0].Devices = q.ToArray(); // = new DeviceConfig() { CoordinatorID = 0, RmkID = infos[i].RmkID ,MAC=infos[i].MAC}; //} Config.WriteXml(config, "config.xml"); }