O'Reilly logo

Professional C# 6 and .NET Core 1.0 by Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16 Reflection, Metadata, and Dynamic Programming

What’s In This Chapter?

  • Using custom attributes
  • Inspecting the metadata at runtime using reflection
  • Building access points from classes that enable reflection
  • Understanding the Dynamic Language Runtime
  • Working with the dynamic type
  • Hosting the DLR ScriptRuntime
  • Creating dynamic objects with DynamicObject and ExpandoObject

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • LookupWhatsNew
  • TypeView
  • VectorClass
  • WhatsNewAttributes
  • DLRHost
  • Dynamic
  • DynamicFileReader
  • ErrorExample

Inspecting Code at RunTime and Dynamic Programming

This chapter focuses on custom attributes, reflection, and dynamic programming. Custom attributes are mechanisms that enable you to associate custom metadata with program elements. This metadata is created at compile time and embedded in an assembly. Reflection is a generic term that describes the capability to inspect and manipulate program elements at runtime. For example, reflection allows you to do the following:

  • Enumerate the members of a type
  • Instantiate a new object
  • Execute the members of an object
  • Find out information about a type
  • Find out information about an assembly
  • Inspect the custom attributes applied to a type
  • Create and compile a new assembly

This list represents a great deal of functionality and encompasses ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required