当前位置: 首页>>代码示例>>C#>>正文


C# RAMDirectory.GetLockFactory方法代码示例

本文整理汇总了C#中Lucene.Net.Store.RAMDirectory.GetLockFactory方法的典型用法代码示例。如果您正苦于以下问题:C# RAMDirectory.GetLockFactory方法的具体用法?C# RAMDirectory.GetLockFactory怎么用?C# RAMDirectory.GetLockFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Store.RAMDirectory的用法示例。


在下文中一共展示了RAMDirectory.GetLockFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestRAMDirectoryNoLocking

		public virtual void  TestRAMDirectoryNoLocking()
		{
			Directory dir = new RAMDirectory();
			dir.SetLockFactory(NoLockFactory.GetNoLockFactory());
			
			Assert.IsTrue(typeof(NoLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory.setLockFactory did not take");
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			
			// Create a 2nd IndexWriter.  This is normally not allowed but it should run through since we're not
			// using any locks:
			IndexWriter writer2 = null;
			try
			{
				writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
			}
			catch (System.Exception e)
			{
				System.Console.Out.WriteLine(e.StackTrace);
				Assert.Fail("Should not have hit an IOException with no locking");
			}
			
			writer.Close();
			if (writer2 != null)
			{
				writer2.Close();
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:28,代码来源:TestLockFactory.cs

示例2: TestDefaultRAMDirectory

		public virtual void  TestDefaultRAMDirectory()
		{
			Directory dir = new RAMDirectory();
			
			Assert.IsTrue(typeof(SingleInstanceLockFactory).IsInstanceOfType(dir.GetLockFactory()), "RAMDirectory did not use correct LockFactory: got " + dir.GetLockFactory());
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			
			// Create a 2nd IndexWriter.  This should fail:
			IndexWriter writer2 = null;
			try
			{
				writer2 = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
				Assert.Fail("Should have hit an IOException with two IndexWriters on default SingleInstanceLockFactory");
			}
			catch (System.IO.IOException e)
			{
			}
			
			writer.Close();
			if (writer2 != null)
			{
				writer2.Close();
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:25,代码来源:TestLockFactory.cs


注:本文中的Lucene.Net.Store.RAMDirectory.GetLockFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。