本文整理汇总了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).
}
示例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)*/);
}
}
示例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
}
}