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
  • SetProperty
  • Dump

Was this helpful?

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

Object

SetProperty

Sets property of source instance to specified value. When property with provided name doesn't exist then nothing happens.

var foo = new Foo { BarProperty = new Bar() };
foo.SetProperty("BarProperty.BarId", 9); // sets value of nested property BarId to 9

Dump

Dumps all object's properties into string for specified count of levels depth.

var foo = new Foo
{
    Id = 1,
    BarProperty = new Bar
    {
        BarId = 2,
        BazProperty = new Baz
        {
            BazId = 3,
            BazName = "SomeBaz"
        }
    },
    Flag = true
};
var result = foo.Dump(3);

// results in:
// {Structr.Tests.Abstractions.Extensions.ObjectExtensionsTests+Foo(HashCode:31071611)}
//   Id: 1
//   BarProperty: { }
//     {Structr.Tests.Abstractions.Extensions.ObjectExtensionsTests+Bar(HashCode:63566392)}
//       BarId: 2
//       BazProperty: { }
//   Flag: True
PreviousMemberInfoNextQueryable

Last updated 2 years ago

Was this helpful?