Structr
  • Welcome
  • Utilities
    • Abstractions
      • Check
      • Ensure
      • Money
      • HierarchyId
      • Providers
        • SequentialGuidProvider
      • Extensions
        • DateTime
        • Dictionary
        • DirectoryInfo
        • Enumerable
        • Enum
        • Expression
        • Int
        • Long
        • MemberInfo
        • Object
        • Queryable
        • ServiceCollection
        • String
        • Type
      • Helpers
        • AsyncHelper
        • BindHelper
      • JsonConverters
        • DateOnly
        • TimeOnly
        • StringNumber
    • Collections
      • AutoMapper extensions
    • IO
      • FileHelper
      • MimeTypeHelper
      • PathHelper
      • SequentialFileName
    • Configuration
      • Providers
        • JSON-file
        • XML-file
        • In-Memory
        • Consul
      • Get settings
      • Set settings
      • Customization
    • Email
      • Razor
    • Navigation
      • Menu
      • Breadcrumbs
    • Security
  • Domain
    • Domain
      • Entities
      • Value objects
  • Data Access
    • Entity Framework Core
    • Entity Framework 6
  • Use Cases
    • Operations
      • Filtering
      • Decoration
    • Notices
    • Validation
    • Specifications
    • Stateflows
      • StateMachine
      • Configurations
  • Presentation
    • ASP.NET Core
      • Client
      • Http
      • JavaScript
      • Json
      • Mvc
      • Referrer
      • Rewrite
      • Routing
      • TagHelpers
      • Validation
Powered by GitBook
On this page
  • HasOwnProperty
  • HasNestedProperty
  • IsNullableEnum
  • GetPropertyInfo
  • IsAssignableFromGenericType

Was this helpful?

Edit on GitHub
  1. Utilities
  2. Abstractions
  3. Extensions

Type

HasOwnProperty

Gets a value indicating whether public non-static property with a specified name occurs directly within this type.

private class Foo
{
    public Bar BarProperty { get; set; }
    public int BarField;
}
public class Bar
{
    public int BarId { get; set; }
}

typeof(Foo).HasOwnProperty("BarProperty") // ---> true
typeof(Foo).HasOwnProperty("BarProperty.BarId") // ---> false

HasNestedProperty

Gets a value indicating whether property with a specified name occurs within this type or its "nested" types.

typeof(Foo).HasNestedProperty("BarProperty.BarId") // ---> true

IsNullableEnum

Gets a value indicating whether source type is nullable enumeration.

private enum FooBar
{
    Foo,
    Bar
}
var result = typeof(FooBar).IsNullableEnum(); // ---> false
var result = typeof(FooBar?).IsNullableEnum(); // ---> true

GetPropertyInfo

Returns PropertyInfo by full property name or null if no property was found.

typeof(Foo).GetPropertyInfo("BarProperty.BarId"); // ---> PropertyInfo instance for BarId

IsAssignableFromGenericType

Determines whether an instance of a specified type can be assigned to an instance of the current type taking into account generic nature of specified type.

private interface IFooGeneric1<T1, T2> { }
private class FooGeneric2<T> : IFooGeneric1<T, DateTime> { }

var result = typeof(IFooGeneric1<,>).IsAssignableFromGenericType(typeof(FooGeneric2<>)); // ---> true
PreviousStringNextHelpers

Last updated 2 years ago

Was this helpful?