You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/02/28 12:30:03 UTC
[12/20] lucenenet git commit:
Lucene.Net.Core.Support.Util.NamedServiceFactory: Fixed IsServiceType() and
GetServiceName() methods to support .NET Core.
Lucene.Net.Core.Support.Util.NamedServiceFactory: Fixed IsServiceType() and GetServiceName() methods to support .NET Core.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/5c3392d2
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/5c3392d2
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/5c3392d2
Branch: refs/heads/api-work
Commit: 5c3392d2218ad85d67cc0b4fd9369c5de086bd5a
Parents: 56307f1
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Tue Feb 28 08:34:48 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Tue Feb 28 08:34:48 2017 +0700
----------------------------------------------------------------------
.../Support/Util/NamedServiceFactory.cs | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/5c3392d2/src/Lucene.Net.Core/Support/Util/NamedServiceFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Util/NamedServiceFactory.cs b/src/Lucene.Net.Core/Support/Util/NamedServiceFactory.cs
index 343f476..06af811 100644
--- a/src/Lucene.Net.Core/Support/Util/NamedServiceFactory.cs
+++ b/src/Lucene.Net.Core/Support/Util/NamedServiceFactory.cs
@@ -1,4 +1,5 @@
\ufeffusing System;
+using System.Linq;
using System.Reflection;
namespace Lucene.Net.Util
@@ -44,10 +45,10 @@ namespace Lucene.Net.Util
{
return
type != null &&
- type.IsPublic &&
- !type.IsAbstract &&
+ type.GetTypeInfo().IsPublic &&
+ !type.GetTypeInfo().IsAbstract &&
typeof(TService).GetTypeInfo().IsAssignableFrom(type) &&
- type.GetCustomAttributes(typeof(IgnoreServiceAttribute), inherit: true).Length == 0;
+ type.GetTypeInfo().GetCustomAttribute<IgnoreServiceAttribute>(inherit: true) == null;
}
/// <summary>
@@ -57,11 +58,11 @@ namespace Lucene.Net.Util
/// <returns>The canonical name of the service or the name provided in the corresponding name attribute, if supplied.</returns>
public static string GetServiceName(Type type)
{
- // Check for CodecName attribute
- object[] nameAttributes = type.GetCustomAttributes(typeof(ServiceNameAttribute), inherit: true);
- if (nameAttributes.Length > 0)
+ // Check for ServiceName attribute
+ var nameAttributes = type.GetTypeInfo().GetCustomAttributes(typeof(ServiceNameAttribute), inherit: true);
+ if (nameAttributes.Any())
{
- ServiceNameAttribute nameAttribute = nameAttributes[0] as ServiceNameAttribute;
+ ServiceNameAttribute nameAttribute = nameAttributes.FirstOrDefault() as ServiceNameAttribute;
if (nameAttribute != null)
{
string name = nameAttribute.Name;