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


C# IResourceLoader.NewInstance方法代码示例

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


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

示例1: assertClasspathDelegation

 private void assertClasspathDelegation(IResourceLoader rl)
 {
     // try a stopwords file from classpath
     CharArraySet set = WordlistLoader.GetSnowballWordSet(new System.IO.StreamReader(rl.OpenResource(System.IO.Path.GetFullPath(@"..\..\..\Lucene.Net.Analysis.Common\Analysis\Snowball\english_stop.txt")), Encoding.UTF8), TEST_VERSION_CURRENT);
     assertTrue(set.contains("you"));
     // try to load a class; we use string comparison because classloader may be different...
     assertEquals("Lucene.Net.Analysis.Util.RollingCharBuffer", rl.NewInstance<object>("Lucene.Net.Analysis.Util.RollingCharBuffer").ToString());
     // theoretically classes should also be loadable:
     //IOUtils.CloseWhileHandlingException(rl.OpenResource("java/lang/String.class")); // LUCENENET TODO: Not sure what the equivalent to this is (or if there is one).
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:10,代码来源:TestFilesystemResourceLoader.cs

示例2: Inform

 public virtual void Inform(IResourceLoader loader)
 {
     if (encoderClass.Equals("float"))
     {
         encoder = new FloatEncoder();
     }
     else if (encoderClass.Equals("integer"))
     {
         encoder = new IntegerEncoder();
     }
     else if (encoderClass.Equals("identity"))
     {
         encoder = new IdentityEncoder();
     }
     else
     {
         encoder = loader.NewInstance<IPayloadEncoder>(encoderClass /*, typeof(PayloadEncoder)*/);
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:19,代码来源:DelimitedPayloadTokenFilterFactory.cs

示例3: assertNotFound

 private void assertNotFound(IResourceLoader rl)
 {
     try
     {
         IOUtils.CloseWhileHandlingException(rl.OpenResource("/this-directory-really-really-really-should-not-exist/foo/bar.txt"));
         fail("The resource does not exist, should fail!");
     }
     catch (IOException)
     {
         // pass
     }
     try
     {
         rl.NewInstance<TokenFilterFactory>("org.apache.lucene.analysis.FooBarFilterFactory");
         fail("The class does not exist, should fail!");
     }
     catch (Exception)
     {
         // pass
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:21,代码来源:TestFilesystemResourceLoader.cs


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