public static bool AddItem(TrustedLeafItem item) { if (IsTrusted(item)) { return(false); } items.Add(item); using (SQLiteConnection connection = new SQLiteConnection("Data Source=\"" + DataPath + "\"")) { connection.Open(); String query = @"insert into trusted (name, guid) values (@name, @guid)"; using (SQLiteCommand command = new SQLiteCommand(query, connection)) { command.Parameters.Add(new SQLiteParameter("@name", item.Name)); command.Parameters.Add(new SQLiteParameter("@guid", item.Guid.ToString())); command.ExecuteNonQuery(); } } return(true); }
public static void RemoveItem(TrustedLeafItem item) { using (SQLiteConnection connection = new SQLiteConnection("Data Source=\"" + DataPath + "\"")) { connection.Open(); String query = @"delete from trusted where name=@name and guid=@guid"; using (SQLiteCommand command = new SQLiteCommand(query, connection)) { command.Parameters.Add(new SQLiteParameter("@name", item.Name)); command.Parameters.Add(new SQLiteParameter("@guid", item.Guid.ToString())); command.ExecuteNonQuery(); } } items.RemoveAll(x => x.Guid.Equals(item.Guid) && x.Name == item.Name); }
public static bool IsTrusted(TrustedLeafItem item) { return(items.Find(x => x.Guid.Equals(item.Guid) && x.Name == item.Name) != null); }