-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
600 additions
and
603 deletions.
There are no files selected for viewing
54 changes: 27 additions & 27 deletions
54
src/NSwag.Core/CodeGeneration/Infrastructure/ReflectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ReflectionExtensions.cs" company="NSwag"> | ||
// Copyright (c) Rico Suter. All rights reserved. | ||
// </copyright> | ||
// <license>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</license> | ||
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
namespace NSwag.CodeGeneration.Infrastructure | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ReflectionExtensions.cs" company="NSwag"> | ||
// Copyright (c) Rico Suter. All rights reserved. | ||
// </copyright> | ||
// <license>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</license> | ||
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
namespace NSwag.CodeGeneration.Infrastructure | ||
{ | ||
/// <summary>Provides extension methods for reflection.</summary> | ||
public static class ReflectionExtensions | ||
{ | ||
public static class ReflectionExtensions | ||
{ | ||
/// <summary>Checks whether the given type inherits from the given type name.</summary> | ||
/// <param name="type">The type.</param> | ||
/// <param name="typeName">Name of the type.</param> | ||
/// <returns>true if the type inherits from typeName.</returns> | ||
public static bool InheritsFrom(this Type type, string typeName) | ||
{ | ||
var baseType = type.GetTypeInfo().BaseType; | ||
while (baseType != null) | ||
{ | ||
if (baseType.Name == typeName) | ||
return true; | ||
baseType = baseType.GetTypeInfo().BaseType; | ||
} | ||
return false; | ||
} | ||
} | ||
} | ||
public static bool InheritsFrom(this Type type, string typeName) | ||
{ | ||
var baseType = type.GetTypeInfo().BaseType; | ||
while (baseType != null) | ||
{ | ||
if (baseType.Name == typeName) | ||
return true; | ||
baseType = baseType.GetTypeInfo().BaseType; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.