public static void GetAllSongs(System.Collections.ObjectModel.ObservableCollection <Song> songs) { var allSongs = GetSongs(); songs.Clear(); allSongs.ForEach(song => songs.Add(song)); }
/// <summary> /// /// </summary> public void Query() { var pps = DBDevelopClientApi.DevelopServiceHelper.Helper.GetAllDatabasePermission(Database); mPermissions.Clear(); foreach (var vv in pps) { var pp = new PermissionItemViewModel(vv); mPermissions.Add(pp); } }
/// <summary> /// 비동기 추가 /// ObservableCollection<T>가 null이면 생성하여 추가 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection"></param> /// <param name="datatable"></param> public static void ToObservableCollection <T>(this System.Collections.ObjectModel.ObservableCollection <T> collection, DataTable dataTable) { if (collection == null) { //throw new Exception(collection.GetType().Name + " Is Null"); } collection.Clear(); foreach (var item in DataTableToList <T>(dataTable)) { collection.Add(item); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); databaseAddress = createAddress(); connection = new SqlConnection(databaseAddress.ConnectionString); // Create your application here TextView scanview = FindViewById <TextView>(Resource.Id.scanview); TextView txt = FindViewById <TextView>(Resource.Id.txtdata); listView = FindViewById <ListView>(Resource.Id.listView1); txt.Text += clientId; ble = CrossBluetoothLE.Current; adapter = CrossBluetoothLE.Current.Adapter; deviceList = new ObservableCollection <IDevice>(); Button Test = FindViewById <Button>(Resource.Id.btnTest); Test.Click += delegate { var state = ble.State; var info = ble.State.ToString(); new AlertDialog.Builder(this) .SetMessage(info) .SetTitle("Bluetooth State") .Show(); }; Button button = FindViewById <Button>(Resource.Id.dbbutton); button.Click += delegate { //var db = new SQLiteConnection(dbPath); ////set up table //db.CreateTable<Contact>(); ////create new contact obj Contact myContact = new Contact(clientId, prevLocation); ////store obj into table //db.Insert(myContact); connection.Open(); StringBuilder query = new StringBuilder(); query.Append("INSERT INTO UsersTable(Username, Location)VALUES('" + myContact.Name + "', '" + myContact.Location + "')"); string sqlquery = query.ToString(); SqlCommand command = new SqlCommand(sqlquery, connection); command.ExecuteNonQuery(); connection.Close(); }; Button showbutton = FindViewById <Button>(Resource.Id.showbtn); showbutton.Click += delegate { //set up db connection var db = new SQLiteConnection(dbPath); //connect to table var table = db.Table <Contact>(); foreach (var item in table) { Contact myContact = new Contact(item.Name, item.Location); txt.Text += myContact + "\n"; } }; Button BLEscan = FindViewById <Button>(Resource.Id.scanner); BLEscan.Click += async delegate { scanview.Text = ""; deviceList.Clear(); adapter.DeviceDiscovered += (s, a) => { deviceList.Add(a.Device); }; await adapter.StartScanningForDevicesAsync(); scanview.Text += "Device count:" + deviceList.Count; List <IDevice> x = deviceList .Where(device => device.Name != null) //&& device.Rssi > -30) .ToList(); scanview.Text += "Var X:" + x.Count; CreateList(x); prevLocation = x.ElementAt(0).Name; }; }
/// <summary> /// Removes all elements from the <see cref="T:System.Collections.Generic.List`1" />. /// </summary> public void Clear() { _innerCollection.Clear(); }