Download presentation
Presentation is loading. Please wait.
Published byKory Crawford Modified over 9 years ago
1
MIDDLE WARE TECHNOLOGIES B.TECH III YR II SEMESTER UNIT 4 PPT SLIDES TEXT BOOKS: 1.Client/Server programming with Java and CORBA Robert Orfali and Dan Harkey, John Wiley & Sons,SPD 2nd Edition 2. Java programming with CORBA 3rd Edition, G.Brose, A Vogel and K.Duddy, Wiley- dreamtech, India John wiley and sons
2
INDEX UNIT 4 PPT SLIDES S.NO. TOPIC LECTURE NO. PPTSLIDES 1. BUILDING C# APPLICATIONS L24 L1.1 TO L1.4 2. TYPE REFLECTIONS L25 L2. 1 TO L2.4 3. LATE BINDING L26 L3. 1 TO L3.5 4. ATTRIBUTE BASED PROG. L27 L4. 1 TO L4.5 5. OBJECT SERIALIZATION L28 L5. 1 TO L5.5 6. REMOTE LAYER L29 L6. 1 TO L6.4 7. ADO.NET L30 L7. 1 TO L7.4 8. WEB SERVICES L31 L8. 1 TO L8.5
3
UNIT4 SYLLABUS Building C# applications: Type Reflection, Late Binding, and Attribute- Based programming; object Serialization and the NET Remoting Layer; Data Access with ADO.NET;XML Web Services.
4
lecture 1 slide 1 BUILDING C# APPLICATIONS The necessity of type meta data ability to fully qualify the definition of types Numerous.NET technologies Cross language interoperability .Net type is any member from the set . Net type is the vehicle used to describe internal composition Using ildasm.exe we can view assemblies
5
lecture 1 slide 2 BUILDING C# APPLICATIONS The Role of the Command Line Compiler (csc.exe) The most obvious reason is the simple fact that you might not have a full copy of Visual Studio.NET (but do have the free.NET SDK). Another reason is this very important fact: Design time editors, code Wizards, and configuration dialogs do little more than save you typing time. The more you understand what happens "under the hood" the stronger your programming muscle becomes. As you use VS.NET to build applications,
6
lecture 1 slide 3 BUILDING C# APPLICATIONS To equip your development machine to compile *.cs files from any subdirectory, follow these steps (which assume a Windows XP installation; WinNT/Win2000 steps will slightly differ): Right-click the My Computer icon and select Properties from the pop-up menu. Select the Advanced tab and click the Environment Variables button. Double click the Path variable from the System Variables list box.
7
lecture 1 slide 4 BUILDING C# APPLICATIONS To equip your development machine to compile *.cs files from any subdirectory, follow these steps (which assume a Windows XP installation; WinNT/Win2000 steps will slightly differ): Right-click the My Computer icon and select Properties from the pop-up menu. Select the Advanced tab and click the Environment Variables button. Double click the Path variable from the System Variables list box.
8
lecture 2 slide 1 TYPE REFLECTIONS System reflection name space Assembly contains a number of methods that allow to load Assembly name to discover version iformation Event info Holds information for a given field Member info Abstract base class that defines common behaviours
9
lecture 2 slide 2 TYPE REFLECTIONS Method info Contains information for a given method Module Allows you to access given module Parameter info Holds information for a given parameter Property info Holds informtion for a given property
10
lecture 2 slide 3 TYPE REFLECTIONS Type Member Meaning in Life IsAbstract IsArray IsClass IsCOMObject IsEnum IsInterface IsPrimitive IsNestedPublic IsNestedPrivate IsSealed IsValueType These properties (among others) allow you to discover a number of basic traits about the Type you are referring to (e.g., if it is an abstract method, an array, a nested class, and so forth).
11
lecture 2 slide 4 TYPE REFLECTIONS –GetConstructors() –GetEvents() –GetFields() –GetInterfaces() –GetMethods() –GetMembers() –GetNestedTypes() –GetProperties() These methods (among others) allow you to obtain an array representing the items (interface, method, property, etc.) you are interested in. Each method returns a related array (e.g., GetFields() returns a FieldInfo array,
12
lecture 3 slide 1 TYPE REFLECTIONS GetMethods() returns a MethodInfo array, etc.). Be aware that each of these methods has a singular form (e.g.GetMethod() GetProperty()) that allows you to retrieve a specific item by name, rather than an array of all related items. FindMembers() Returns an array of MemberInfo types, based on search criteria. GetType() This static method returns a Type instance given a string name. InvokeMember() This method allows late binding to a given item.
13
lecture 3 slide 2 LATE BINDING A Sampling of Members of the System.Reflection Assembly This class (in addition to numerous related types) contains a number of methods that allow you to load, investigate, and manipulate an assembly. AssemblyName This class allows you to discover numerous details behind an assembly's identity (version information, culture information, and so forth). EventInfo Holds information for a given event. FieldInfo Holds information for a given field.
14
lecture 3 slide 3 LATE BINDING A Sampling of Members of the System.Reflection Member Info This is the abstract base class that defines common behaviors for the Event Info, Field Info, Method Info, and Property Info types. Method Info Contains information for a given method. Module Allows you to access a given module within a multifile assembly. Parameter Info Holds information for a given parameter. Property Info Holds information for a given property.
15
lecture 3 slide 4 LATE BINDING CSharpSnapIn.dll: A simple snap-in written in C#, which leverages the types of CommonSnappableTypes.dll. VbNetSnapIn.dll: A simple snap-in written in VB.NET, which leverages the types of CommonSnappableTypes.dll. MyPluggableApp.exe: This Windows Forms application will be the entity that may be extended by the functionality of each snap-in. Again, remember! This application will make use of reflection, late binding, and custom attributes to dynamically gain the functionality of assemblies it has no foreknowledge.
16
lecture 3 slide 5 LATE BINDING The Activator Class The System.Activator class is the key to.NET late binding. Beyond the methods inherited from Object, Activator only defines a small set of members. Activator.CreateInstance() is one core method that creates an instance of a type at runtime. This method has been overloaded numerous times to provide a good deal of flexibility.
17
lecture 4 slide 1 LATE BINDING // Create a type dynamically. public class LateBind { public static int Main(string[] args) { // Assume the CarLibrary is in the app directory. Assembly a = null; try { a = Assembly.Load("CarLibrary"); } catch(FileNotFoundException e) { Console.WriteLine(e.Message);} // Specify the fully qualified name of the Minivan type. Type miniVan = a.GetType("CarLibrary.MiniVan"); // Create the Minivan on the fly. object obj = Activator.CreateInstance(miniVan); }
18
lecture 4 slide 2 ATTRIBUTE PROGRAMMING IDL is the official metlanguage of the com (Computer ObjectModel). IDL makes use of “attributes”, which are IDL keyword, placed in square load etc. Ex.: [object, unid (4CB8B79A-E991-4AA4….), oleautomation] ------ parameters can be passed with [in],[int], [in,int], and [out, retral] attributes. C# and other.NET-aware languages have inteprated attributes as official aspects of the language..NET attributes (predefined or custom) are classes, all of which extend System. Attribute
19
lecture 4 slide 3 ATTRIBUTE PROGRAMMING Predefined.NET AttributeMeaning 1. CLSCompliantEnforces that all types in the assembly conform to the CommonLanguageSpecification (CLS). 2. DllImportUsed to make calls to the native OS. 3. StructLayoutUsed to configure the underlyingrepresentation of a Structure. 4. DispidSpecifies the DISPID for a member in a com dispinterface. 5. Serializable Marks a class or structure as being serializable. 6. NonserializedSpecifies that a given field in a class or structure is not serializable. 7. WebMethodMarks a method as being invokable Via HTTP requests.
20
lecture 4 slide 4 ATTRIBUTE PROGRAMMING Object Graphs: The chain of related objects serialized to a stream is collectively referred to as an object graph. Object graphs provide a simple way to document how a set of objects refer to each other. To establish the relations among objects in a graph, each object is assigned a unique numeral value, followed by a graph of all related items.
21
lecture 4 slide 5 ATTRIBUTE PROGRAMMING Ex. : // This class can be saved to disk. [Serializable] – class itself is serializable public class Motorcycle { bool hasRadioSystem; bool hasHeadSet; bool has SissyBar; // but when you do, don’t bother with this field. [NonSerialized] – need not be saved. Float weightofCurrentPassengers; }
22
lecture 5 slide 1 OBJECT SERIALIZATION Serialization: Process of converting the state of an object to a linear sequence of data is termed as Serialization. This data sequence contains all necessary information needed to reinstruct (or deserialize) the state of the object for use later. The.NET serialization services are quite sophisticated: When a given object is serialized to a stream, any associated object references required by the root object are automatically serialized as well.
23
lecture 5 slide 2 OBJECT SERIALIZATION Once a set of objects has been saved to a stream, the data pattern can be relocated as necessary. For ex., if you have serialized an object group into memory location using the system.IO.MemoryStream type. This stream could be forwarded to a remote Computer, the Windows Clipboard, burned to a CD, or simply written to a physical file.
24
lecture 5 slide 3 OBJECT SERIALIZATION Configuring Objects for Serialization: 1. To make an object available to.NET serialization services, decorate each class with the [serializable] attribute. 2. If you have some member data in a given class that should not participate in the serialization scheme, you can mark such fields with the [Non Serialized] attribute – applicable for ex., for constants, transient data etc.
25
lecture 5 slide 4 OBJECT SERIALIZATION Ex. // The Radio class can participate in the.NET serialization [Serializable] public class Radio { // this member will not be persisted. [Non Serialized] private int objectIDNumber = 9; //Other Serialized state data. … public Radio( ) {} public void On (bool state) { if (state = = true) MessagBox.Show(“Music is on …”); else MessageBox.Show (“No tunes…”); }
26
lecture 5 slide 5 OBJECT SERIALIZATION Choosing a serilization formatter The system run time serialization fromatters namespace contains two additional nested namespaces (* Binary *soap). The binary formatter type serializes your object graph to a stream using a compact binary format. The soap formatter type represents your graph as SOAP (single object Access Protocol) message that is expressed using XML data representation. The system.Runtime.Serilization.Formatters.Binary.Binary Formatter type is define within mscorlit.dll; Ex: //persist object graph using a binary format!
27
lecture 6 slide 1 OBJECT SERIALIZATION Choosing a serilization formatter Using system.runtime.serizlization.formatters.binary; The systm.runtime. Serilization.Formatters. Soap.Formatter type is defined in a separate assembly. To format your object graph in to a SOAP message, you must set a reference to system.runtime. Serilization.Formatters.Soap.all and make the following C++ using directive. Ex: //persist object graph using a SOAP format! Using system. runtime.serizlization.formatters.Soap;
28
lecture 6 slide 2 REMOTE LAYER.NET Remoting An application domain is a logical boundary for a.NET assembly which is itself contained within a process type. In the context of distributing computing under.NET, remoting is the act of two pieces of s/w communicating across app.domains. Possible scenarios for the app.domains: –Two app. domains in the same process (and thus on the same machine). –Two app.domains in separate process on the same machine. –Two app.domains in separate process on difference machines. Regardless of the distance between two softwares entities, it is common to refer to each agent using the terms client and server. client is a piece of software that attempts to interact with a remote object. server is the software agent that provides remote access to select objects.
29
lecture 6 slide 4 REMOTE LAYER The.NET Remoting namespaces: The.NET base class libraries provide numerous namespaces that allow you to build dist.apps. The bulk of the types found with in these namespaces are contained with in mscorlib.dll. The system.Runtime.Remoting.dll assembly does complement and extend the basic type set.
30
lecture 7 slide 1 REMOTE LAYER Remoting – Centric NamespaceMeaning System.Runtime.RemotingCure n/s, you must use when building any sort of app. Using the.NET Remoting layer System.Runtime.Remoting ActivationSmall n/s, to fine- tune the process activating a remote object. System.Runtime.Remoting ChannelsTypes to represent channels and channel links. System.Runtime.Remoting Channels.HttpTypes that use the HTTP protocol to transport messages and objects to and from remote locations. System.Runtime.Remoting Channels tcpTypes that use the TCP protocol to transport messages and objects to and from remote locations.
31
lecture 7 slide 2 REMOTE LAYER System.Runtime.Remoting contextsto configure the details of a object’s context. System.Runtime.Remoting. lifetimeto manage the lifetime of remoting objects. System.Runtime.Remoting. Messagingto create and transmit message object. System.Runtime.Remoting. Metadatato customize the generation and processing of SOAP formatting. System.Runtime.Remoting. Metadatatypes that represent the XML scheme def. System.Runtime.Remoting.metadata useful for soapsuds.exe command line tool services. to convert.NET metadata to and from XML schema for the remoting infrastructure. System.Runtime.Remoting.Proxiesprovide functionality for proxy objects
32
lecture 7 slide 3 REMOTE LAYER The.NET Remoting Framework: When clients and servers exchange information. across app. Boundaries, the CLR makes use of several low-level primitives to ensure the entities in question are able to communicate with each other as transparently as possible. The.NET Remoting layer revolves around a careful orchestration that takes place between four key players: Proxies, Messages, Channels and Formatters.
33
lecture 7 slide 4 REMOTE LAYER Proxies & Messages: Like Java RI, CORBA and DCOM, the role of a.NET Proxy is to fool the client into believing it is communicating with a local object in the same app.domain. A proxy has the identical interface (i.e., members, properties, fields etc) as the remote type it represents. The proxy invoked directly by the client is termed the transparent proxy. It is generated by CLR and ensures that the client has provided the current no.of and type of parameters to invoke the remote method. Transparent proxies cannot be modified or extended programmatically. The incoing args. Infn. is packaged up into another CLR generated type termed the message object
34
lecture 8 slide 1 ADO.NET
35
lecture 8 slide 2 ADO.NET Interfaces IDb Connection IDb Transaction IDb Command IDb Data Parameter IData Parameter IDb Data Adapter I Data Adapter I Data Reader I Data Reused
36
lecture 8 slide 3 ADO.NET ADO.NET Namespaces: System Data System Data. common System Data. OleDb System Data. Odbc System Data.Oracle client System Data.Sql client System Data.Sql server System Data.Sql types
37
lecture 8 slide 4 ADO.NET Key members of System.Data Data Column collection, Data Column Constraint collection, constraint Data Row collection, Data row Data Row view, Data View Data set Foreign key constraint, unique constraint Data Relation Collection, Data relation Data Table collection, Data table
38
lecture 8 slide 5 ADO.NET Mapping type enumeration: Enum valueCol. is mapped to Attribute- XML attribute Element-XML element (default) Hidden -internal structure Simple content-text
39
lecture 8 slide 6 Web Service A programmable application logic accessible by all the internet users just-like components represents a new platform on which developers can build the same distributed applications they've always built with interoperability as the highest priority..NET uses standard internet protocols like HTTP, SOAP and XML whereas other components uses DCOM, RMI or Internet Inter-ORB (IIOP) protocols Widely required for Enterprise Application Integration (EAI) and Business-to-Business Integration (B2Bi) applications.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.