1 / 27

What We Will Learn

C#. What We Will Learn. Configuration and Support Compiler Options Globalization Writing CLS Compliant Code XML Documentation Delegates Async Processing Callbacks Subscribing To and Publishing Events Developing Data Consumers and Services Data Transformation

erno
Download Presentation

What We Will Learn

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. C#

  2. What We Will Learn • Configuration and Support • Compiler Options • Globalization • Writing CLS Compliant Code • XML Documentation • Delegates • Async Processing • Callbacks • Subscribing To and Publishing Events • Developing Data Consumers and Services • Data Transformation • Distributed Application Programming • Multithreading • Using Structs and Arrays • Grammar • Escape Characters • Operators and Their Precedence • Preprocessing Directives • Program Flow • Statements and Expressions

  3. What We Will Learn • Methods • Operator Overloading • Parameters • Pinvoke • Special Methods • User-Defined Conversions • Object-Oriented Programming • Aggregation • Encapsulation and Abstraction • Inheritance and Polymorphism • Properties, Indexers, and Fields • Constants and Fields • Indexers • Properties • Variables • Value and Reference Types • Attributes • Conversions • Object Creation and Lifetime • Structs and Enums

  4. Compiler Options • Can call C# from command line csc.exe • VCVARS32.BAT sets up environment • No linking in C# • csc File.cs produces File.exe • csc /target:library File.cs produces File.dll • csc /out:My.exe File.cs produces My.exe • csc /define:DEBUG /optimize /out:File2.exe *.cs defines DEBUG and sets optimizations on Collaboration

  5. Globalization • System.Globalization.CultureInfo • System.Globalization.Calendar • System.Globalization.DateTimeFormatInfo • System.Globalization.DaylightTime • System.Globalization.GregorianCalendar • System.Globalization.RegionInfo • System.Globalization.SortKey

  6. CLS Compliance • Common Language Specification • Affects.. • Public class definitions • Public members/protected members accessed externally • Params/return types of Public methods of Public classes • ClsCompliantAttribute indicates compliance • [AttributeUsage(AttributeTargets.All)] [Serializable] public sealed class CLSCompliantAttribute : Attribute

  7. XML Documentation • /doc compiler option creates XML documentation • Tags • <c> text within a description that is code • <code> many lines of code • <example> • <exception> • <param> • <returns> • <see> • <seealso> • <summary>

  8. Event Handling • What is an Event? • Event is something interesting that happens to a class • One class can let other interested classes (‘clients’) know when something interesting happens • Clients pass ‘delegates’ to the class they are interested in • Delegates are methods to be instantiated when the event happens • When the event occurs, the class calls the delegates of each of its clients to let them know

  9. Event Handling • Delegates • In the client classes, an event handler must be declared – a method that will be called when the interesting class raises the event • The event handler must conform to the delegate signature • The event handler is then added to the interesting class’s list of event handlers • AlarmEventHandler is the delegate for the Alarm event. • A delegate is a class that can hold a reference to a method. • Unlike other classes, a delegate class has a signature • It can hold references only to methods that match its signature • Note   A delegate declaration is sufficient to define a delegate class. • Event delegates in the .NET Framework have two parameters, the source that raised the event and the data for the event.

  10. Event Handling • Events • In the class of interest, the event is declared and then it is raised within the On method • public event AlarmEventHandler Alarm; //event declared • protected virtual void OnAlarm(AlarmEventArgs e){...} } //method that will raise event • Alarm(this, e); //this call of the event Alarm will be within OnAlarm – in effect it calls each of the event handlers one at a time

  11. Data Transformation • Conversions • Implicit – any type can implicitly convert to a type further down the list • byte • short • integer • long • float/double/decimal • char • Explicit • Convert to/from any numeric type (cast) • Can lose info/raise exceptions • Checked/unchecked

  12. What Is An Assembly? • An assembly is very much like a COM object used to be • It contains the code that the CLR executes • It represents a Fundamental unit • It represents a Security boundary • It represents a Type boundary • It represents a Version boundary • It represents a Deployment unit • It is very much like a Com component or a Java Package

  13. What Is An Assembly? • How is an Assembly created? • Input is MSIL (Microsoft Intermediate Language - like Java Bytecodes) • MSIL is created from your source code (can originally be VB.Net, C#, J# etc.) • MSIL is converted into an ‘assembly manifest’ by Ilasm.exe • Can disassemble an assembly back to MSIL using ildasm.exe

  14. What Is The Global Assembly Cache? • Pool of all Assemblies that are available to be shared by many applications on that computer • Only put Assemblies in Global Assembly Cache if they need to be shared • To install an Assembly in the GAC: • Use a tool called GACUtil.exe • Use an installer designed to do this for you • Use Explorer to drag assemblies into Cache • Must have a strong name to be in GAC

  15. Distributed Applications • Automatic transactions • TransactionAttribute • ServicedComponent class • Base class for all COM+ components • Sign & Register Assembly

  16. Distributed Applications • Sign & Register Assembly • Sign the assembly (use Al.exe) with a strong name to make sure that the assembly contains a unique key pair. • Use the .NET Services Installation Tool (Regsvcs.exe) to manually register the assembly. • A strong name consists of the assembly's identity — its simple text name, version number, and culture information (if provided) — plus a public key and a digital signature. It is generated from an assembly file using the corresponding private key. (The assembly file contains the assembly manifest, which contains the names and hashes of all the files that make up the assembly.)

  17. Distributed Applications • Sign & Register Assembly • Create strong name for assembly using sn • sn -k sgKey.snk • Set file attribute • [assembly:AssemblyKeyFileAttribute(@"..\..\sgkey.snk")] • Remember that once you give an assembly a strong name, all assemblies that reference that assembly also have to have strong names, so that the security of the strongly named assembly is not compromised. • Note   Once an assembly is created, you cannot sign it with a strong name. You can sign an assembly with a strong name only when you create it.

  18. Multithreading

  19. Structs

  20. Arrays

  21. How to Evaluate CMSes • Select Evaluation Process(es) • Formal Tender/RFP process • Makes vendors accountable • Use a standard RFP format http://document-management-software-system.net/rfp_template_db-gen.html#ecms • Demos • Ensure vendors demo similar features • Compare different ways in which your needs can be met • Scoring System • Create a scoring system based upon requirements list (or RFP) to compare

  22. Cost Justification – In Theory • In Theory • Higher productivity • Reduced operating costs • Increased employee satisfaction • Increased customer satisfaction • Enhanced Developer Productivity • Reduced time to value • Improved Scalability/Reliability • Greater Interoperability

  23. Cost Justification – in Practice

  24. The Reality? • Microsoft tool • for determining Cost Justification/ Cost Benefit Analysis • http://www.microsoft.com/cmserver/evaluation/roicalculator.xls • Guide to CMS evaluation • http://www.em3.com/object/googlerightCMsystem.html • Many CMSes are too complex for requirements • Many CMSes are too expensive to buy or implement

  25. The Solution? • Careful requirements gathering • Careful evaluation • Ensure you are fully informed • http://www.cmswatch.com • http://document-management-software-system.net/rfp_template_db-gen.html#ecms • Employ consultants who are fully informed (Apogee Interactive!)

  26. The Solution? • Apogee Interactive Inc. • Susan Gilbert 770 270 6502 • Experts in Content Mgt Solutions, EBusiness and Website solutions

More Related