コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public static bool IsTrusted(TrustedLeafItem item)
 {
     return(items.Find(x => x.Guid.Equals(item.Guid) && x.Name == item.Name) != null);
 }