本文整理汇总了C#中Db.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Db.Dispose方法的具体用法?C# Db.Dispose怎么用?C# Db.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GivenDbWithExternalConnection_WhenDisposed_ConnectionIsNotDisposed
public void GivenDbWithExternalConnection_WhenDisposed_ConnectionIsNotDisposed()
{
var fakeConnection = Substitute.For<IDbConnection>();
var db = new Db(fakeConnection, DbConfig.Default);
db.Dispose();
// External connection should not be disposed with the Db
fakeConnection.DidNotReceive().Dispose();
}
示例2: Main
static void Main (string [] args)
{
Program program = new Program ("TagStoreTest", "0.0", Modules.UI, args);
const string path = "/tmp/TagStoreTest.db";
try {
File.Delete (path);
} catch {}
Db db = new Db (path, true);
Category people_category = db.Tags.CreateCategory (null, "People");
Tag anna_tag = db.Tags.CreateTag (people_category, "Anna");
Tag ettore_tag = db.Tags.CreateTag (people_category, "Ettore");
Tag miggy_tag = db.Tags.CreateTag (people_category, "Miggy");
miggy_tag.SortPriority = -1;
db.Tags.Commit (miggy_tag);
Category places_category = db.Tags.CreateCategory (null, "Places");
Tag milan_tag = db.Tags.CreateTag (places_category, "Milan");
Tag boston_tag = db.Tags.CreateTag (places_category, "Boston");
Category exotic_category = db.Tags.CreateCategory (places_category, "Exotic");
Tag bengalore_tag = db.Tags.CreateTag (exotic_category, "Bengalore");
Tag manila_tag = db.Tags.CreateTag (exotic_category, "Manila");
Tag tokyo_tag = db.Tags.CreateTag (exotic_category, "Tokyo");
tokyo_tag.Category = places_category;
tokyo_tag.Name = "Paris";
db.Tags.Commit (tokyo_tag);
db.Dispose ();
db = new Db (path, false);
Dump (db.Tags.RootCategory, 0);
}
示例3: Main
static void Main (string [] args)
{
Program program = new Program ("PhotoStoreTest", "0.0", Modules.UI, args);
const string path = "/tmp/PhotoStoreTest.db";
try {
File.Delete (path);
} catch {}
Db db = new Db (path, true);
Tag portraits_tag = db.Tags.CreateTag (null, "Portraits");
Tag landscapes_tag = db.Tags.CreateTag (null, "Landscapes");
Tag favorites_tag = db.Tags.CreateTag (null, "Street");
uint portraits_tag_id = portraits_tag.Id;
uint landscapes_tag_id = landscapes_tag.Id;
uint favorites_tag_id = favorites_tag.Id;
Pixbuf unused_thumbnail;
Photo ny_landscape = db.Photos.Create (DateTime.Now.ToUniversalTime (), 1, "/home/ettore/Photos/ny_landscape.jpg",
out unused_thumbnail);
ny_landscape.Description = "Pretty NY skyline";
ny_landscape.AddTag (landscapes_tag);
ny_landscape.AddTag (favorites_tag);
db.Photos.Commit (ny_landscape);
Photo me_in_sf = db.Photos.Create (DateTime.Now.ToUniversalTime (), 2, "/home/ettore/Photos/me_in_sf.jpg",
out unused_thumbnail);
me_in_sf.AddTag (landscapes_tag);
me_in_sf.AddTag (portraits_tag);
me_in_sf.AddTag (favorites_tag);
db.Photos.Commit (me_in_sf);
me_in_sf.RemoveTag (favorites_tag);
me_in_sf.Description = "Myself and the SF skyline";
me_in_sf.CreateVersion ("cropped", Photo.OriginalVersionId);
me_in_sf.CreateVersion ("UM-ed", Photo.OriginalVersionId);
db.Photos.Commit (me_in_sf);
Photo macro_shot = db.Photos.Create (DateTime.Now.ToUniversalTime (), 2, "/home/ettore/Photos/macro_shot.jpg",
out unused_thumbnail);
db.Dispose ();
db = new Db (path, false);
DumpAll (db);
portraits_tag = db.Tags.Get (portraits_tag_id) as Tag;
landscapes_tag = db.Tags.Get (landscapes_tag_id) as Tag;
favorites_tag = db.Tags.Get (favorites_tag_id) as Tag;
ArrayList query_tags = new ArrayList ();
query_tags.Add (portraits_tag);
query_tags.Add (landscapes_tag);
DumpForTags (db, query_tags);
query_tags.Clear ();
query_tags.Add (favorites_tag);
DumpForTags (db, query_tags);
}