Microsoft .NET Interoperability for Beginners - PowerPoint PPT Presentation

microsoft net interoperability for beginners n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Microsoft .NET Interoperability for Beginners PowerPoint Presentation
Download Presentation
Microsoft .NET Interoperability for Beginners

play fullscreen
1 / 82
Microsoft .NET Interoperability for Beginners
67 Views
Download Presentation
kennan
Download Presentation

Microsoft .NET Interoperability for Beginners

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Microsoft .NET Interoperability for Beginners Vjekoslav Babic (Fortempo)

  2. About me Vjekoslav Babić consultant, trainer, blogger, author Twitter: @vjekob Mibuso: Vjeko Blog: vjeko.com Author of many How Do I… videos for MSDN and PartnerSourcefor NAV 2013 and NAV 2013 R2 Co-author of “Implementing Microsoft Dynamics NAV 2009” book

  3. How Other People See Programmers

  4. How Programmers See Other People

  5. What Do Programmers Really Do? • Most of the time?

  6. So, What Do Programmers Do Most of the Time?

  7. % Of Total Time Spent Programming

  8. % Of Total Time Spent Programming in C/AL

  9. 37.5% of All Statistics AreJust Made UpOn The Spot

  10. What are we doing here today? • Basic Concepts • Constructors • Methods • Overloading • Events • Enumerations • Slightly Advanced Concepts • Classes and Interfaces • Arrays and Collections • Enumerators • Generics • Reflection • Creating Assemblies • Creating Control Add-ins

  11. How Are We Doing It? • General concepts • Managing strings and text • Managing dates, times, and numbers • Accessing operating system, file system, and the environment • Managing data, arrays, collections, and streams • Custom assemblies • Client Add-ins

  12. Part One • General concepts

  13. Assemblies • Building blocks of the .NET Framework • Assemblies can be: • Executable files (EXE) • Dynamic Link Libraries (DLL) • Assemblies can be deployed to: • Single application: any folder accessible to a .NET application • All applications: Global Assembly Cache (GAC)

  14. Type • .NET Framework is strongly-typed, very similar to C/AL • Types can be: • Simple • Complex • .NET is object-oriented: • Types can be inherited • Two types of complex types: • Classes • Interfaces

  15. Classes and Interfaces • Both represent complex types (types that contain members) • Classes: • Define the structure • Encapsulate functionality • One class can inherit from only one parent class • Interfaces: • Only define the structure, but not the functionality • Represent behaviors of classes • One class can implement multiple interfaces • By convention, names start with I, and many names end with …able

  16. The DotNet Data Type • Variables of type DotNet give access to .NET Framework • Each DotNet variable specifies: • Assembly • Type • DotNet gives access to: • Methods • Properties • Constructors • Enumerations

  17. Important: Case Sensitivity • All .NET Framework identifiers are CASE SENSITIVE

  18. Part TWO • Managing strings and text

  19. System.String • A powerful class to handle text information. • Maps fully and directly to Text data type in C/AL.

  20. Methods • Equivalent to functionsin C/AL • Methods are defined by their signature. Signature consists of: • Name • Type and kind of parameters (by value, by reference, or output) • Return value can be: • Of specific type • void

  21. System.String Points of Interest

  22. System.Text.StringBuilder • A very powerful class to handle large text data efficiently.

  23. Constructors • Create an instance of a class. • There is no equivalent in C/AL to constructors. • CREATE function for instantiating automation objects is the closest • Typically used to: • Initialize the default state of an object • Execute default initialization logic • Limit instantiation

  24. Syntax of a Constructor • The name of the constructor always matches the class name. • This probably looks confusing in C/AL: • StringBuilder:= StringBuilder.StringBuilder; • (why in the Earth do we need all those StringBuilders?) • Replace the StringBuildervariable name with s, and it’s more manageable: • s := s.StringBuilder; • The syntax of the constructor in C/AL is the following: • Variable := Variable.[Class Name]({argument1, …});

  25. System.Diagnostics.Stopwatch • A simple and useful class to handle time measurements.

  26. Namespace • A higher-level scope used to organize code • Namespace has a many-to-many relationship to assemblies: • One assembly can contain multiple namespaces • The same namespace can span multiple assemblies

  27. System.Text.RegularExpressions • A namespace containing classes for managing regular expressions. • In case you didn’t know: • Regular Expressions (RegEx) are a language used for searching text data through pattern matching • Regular Expressions are SQL of textual data

  28. Overloading • Capability that allows multiple members to use the same name as long as the signature remains different. • C/AL understands overloading of: • Methods • Constructors • .NET supports, but C/AL does not understand overloading of: • Indexers • Operators

  29. Part Three • Managing dates, times, and numbers

  30. System.DateTime • Manages date and time information. • Maps fully and directly to DateTimedata type in C/AL. • Many useful properties and methods.

  31. Properties and Fields • Properties and Fields are members of complex classes that contain a value. • Property: • Always accessible from C/AL • Can be gettable, settable, or both • Field: • Never accessible from C/AL

  32. System.Globalization • Namespace that defines a lot of useful type for managing date and time formats, regional settings, cultures, etc. • Useful classes: • Calendar • CultureInfo • DateTimeFormatInfo • NumberFormatInfo

  33. System.Globalization.Calendar • Manages time division into years, months, weeks, days, etc.

  34. System.Globalization.CultureInfo • Provides access to culture information. Cultures are the heart of the .NET localization/globalization functionality.

  35. System.Globalization.DateTimeFormatInfo • Provides access to date and time formatting information.

  36. System.Globalization.NumberFormatInfo • Provides access to number formatting information.

  37. System.Math • Provides methods for trigonometric, logarithmic, and other common mathematical functions.

  38. System.Numerics.BigInteger • Represents an arbitrarily large integer value, without any theoretical upper or lower bounds.

  39. System.Convert • Converts a base data type to another base data type.

  40. Part Four • Accessing operating system, file system, and the environment

  41. System.IO • Namespace that provides many useful input and output classes.

  42. System.IO.File • Provides static methods for the creation, copying, deletion, moving, and opening of files.

  43. Static objects and methods • Static classes cannot be instantiated • Static methodscan be called on classes • Static classes and members are sharedfor the whole application domain • Microsoft Dynamics NAV Server runs as a single application domain

  44. System.IO.Directory • Exposes static methods for creating, moving, and enumerating through directories and subdirectories.

  45. System.IO.Path • Performs operations on String instances that contain file or directory path information.

  46. System.IO.FileSystemWatcher • Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.

  47. Events • Enable a class to notify other classes when something of interest happens. • Equivalent to C/AL triggers. • Events are not automatically exposed. • You must first set the WithEventsproperty. • Events can run be: • Server-Side: default behavior, if RunOnClientis No • Client-Side: if RunOnClientis Yes