1 / 29

.Net Components And Types

.Net Components And Types. Bassem Elkarablieh. Outline. Modules Assemblies Object Model Types Runtime Type Information Programming with Types. .net Code Journey. CLR Architecture. Modules. CLR programs reside into Modules Modules contain: Code(IL code) MetaData ( module description)

cissy
Télécharger la présentation

.Net Components And Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. .Net Components And Types Bassem Elkarablieh

  2. Outline • Modules • Assemblies • Object Model • Types • Runtime Type Information • Programming with Types

  3. .net Code Journey

  4. CLR Architecture

  5. Modules • CLR programs reside into Modules • Modules contain: • Code(IL code) • MetaData ( module description) • Resources (any external resource) • Modules are not deployable components

  6. Assemblies • Modules are the physical construct of the program that resides in file system • Assembly is a logical construct that interfaces with the CLR to access modules • Assemblies are references by a logical name • The CLR have a mechanism to identify assemblies

  7. Assemblies continued • Assemblies are deployable modules • Each assembly has a manifest • Assemblies might have multiple modules • Only one manifest exists • Manifests describe the modules in the assembly • Assembly can be: • Executable application • Library

  8. Assemblies

  9. Compiling process • csc /t:module Speaker1.cs • csc /t:module Speaker2.cs • csc /t:library /addmodule:Speaker1.netmodule /addmodule:Speaker2.netmodule Speakers.cs • csc /t:exe /r:Speakers.dll Executive.cs

  10. Manifests • Manifests contain: • Filenames of the internal modules • Type declaration of internal modules • Name of the assembly • MetaData Contain • List of all external dependencies • Type declarations of the assembly

  11. Assembly names • Assembly names are four parts: • Logical friendly name • Version number • Culture • Public Key Token • Friendly names: simple name to reference the assembly • Culture: “en-us”,”ar-lb” Satellite

  12. Versioning • Version number have the following structure: • Major.Minor.Build.Revision

  13. Public Keys • Public keys resolves name confusions of assemblies • Public keys signs the module with the developer identity • Private keys can be used to digitally sign the assembly • Public key file can be generated using the sn.exe tool

  14. Loading assemblies • If assembly is partially specified it can be loaded by friendly name • If assembly is fully specified , then the name should be resolved before the assembly is loaded

  15. Loading Assemblies

  16. .net Types • Every class declared in .net is a type • Types can include: • Fields • Methods • Properties • Events

  17. CLR Type System

  18. C++ Object Model

  19. .net Runtime Object Model

  20. Runtime type information object

  21. How to call a method • If the method is a member of the type , then 3 pointer references are used • If the method is a base-member then more references are used depending on the length of the hierarchy

  22. Type Casting • One of the main properties of .net is type safety. • Disadvantage of type checking is performance. • Three types of castings are possible: • Upcast • Downcast • Sidecast

  23. Type Casting • Casting is the process of a linear search and match of the handles in the interface table and the Class hierarchy. • To support casting two opcodes are used( invisible from user) • Isinsit (is keyword) • Castclass(as Keyword) • Both opcode take the object and the desired type metadata pointer as arguments.

  24. Type checking • The System.Type class is a façade to the internal Type structure. • Provides methods to check type compatibility • IsCompatible, Issubclassof • To get the type handle of any object use the inherited object.getType()

  25. Programming With Types

  26. System.Reflection • This namespace provide the Assembly object used in loading assemblies • The assembly object allows the accessing of the typemetadata. • Given the metadata we can get the type handle references. • Given the type Handel we can get member info.

  27. System.Type • Assembly Asm = Assembly.Loadfrom(“x.dll”); • Type[] types = Asm.GetTypes(); • Foreach(Type t in types) • T.GetMembers() • T.GetMethods() • T.GetFields() • T.GetEvents()

  28. Filtering Type selection • Using bindingflags • BindingFlags f = static|Instance|public|nonpublic|FlattenHirarchy • T.GetMembers(f); • We can also filter by name and the member type

  29. End of Presentation

More Related