Module 3: Working with Components. Overview An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating.

Slides:



Advertisements
Similar presentations
ASP.NET Best Practices Dawit Wubshet Park University.
Advertisements

Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
Programming with Objects: Class Libraries and Reusable Code.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
C#.NET C# language. C# A modern, general-purpose object-oriented language Part of the.NET family of languages ECMA standard Based on C and C++
Introduction to the C# Programming Language for the VB Programmer.
Chapter 12: Advanced Topics: Exception Handling Visual Basic.NET Programming: From Problem Analysis to Program Design.
Differences between C# and C++ Dr. Catherine Stringfellow Dr. Stewart Carpenter.
C# vs. C++ What's Different & What's New. An example C# public sometype myfn { get; set; } C++ public: sometype myfn { sometype get (); void set (sometype.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas,
1 CSC241: Object Oriented Programming Lecture No 27.
BASE CLASSES AND INHERITANCE CHAPTER 4. Engineer Class.
Neal Stublen Class Objectives  Develop an understanding of the.NET Framework  Gain proficiency using Visual Studio  Begin learning.
Introduction to Classes SWE 344 Internet Protocols & Client Server Programming.
Module 7: Object-Oriented Programming in Visual Basic .NET
CSC 2720 Building Web Applications Using Java Beans, Custom Tags and Tag Libraries in JSP pages.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Building.NET GUIs for Haskell applications Beatriz Alarcón Jiménez
1.  A method describes the internal mechanisms that actually perform its tasks  A class is used to house (among other things) a method ◦ A class that.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
Keith Elder Microsoft MVP
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
VB and C# Programming Basics. Overview Basic operations String processing Date processing Control structures Functions and subroutines.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Introduction to Exception Handling and Defensive Programming.
ILM Proprietary and Confidential -
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Classes and Multiform Projects.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Module 1: Working with ASP.NET. Overview Introducing ASP.NET Creating Web Forms Adding ASP.NET Code to a Page Handling Page Events Discussion: ASP vs.
Module 1: Getting Started. Introduction to.NET and the.NET Framework Exploring Visual Studio.NET Creating a Windows Application Project Overview Use Visual.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Module 3: Using Microsoft.NET- Based Languages. Overview Overview of the.NET-Based Languages Comparison of the.NET-Based Languages.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
Module 14: Attributes. Overview Overview of Attributes Defining Custom Attributes Retrieving Attribute Values.
Chapter 4 Introduction to Classes, Objects, Methods and strings
Module 8: Delegates and Events. Overview Delegates Multicast Delegates Events When to Use Delegates, Events, and Interfaces.
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
ASP.NET User Controls. User Controls In addition to using Web server controls in your ASP.NET Web pages, you can create your own custom, reusable controls.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
Chapter 6 - More About Problem Domain Classes1 Chapter 6 More About Problem Domain Classes.
Module 1 Introducing C# and the.NET Framework. Module Overview Introduction to the.NET Framework 4 Creating Projects Within Visual Studio 2010 Writing.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Session 02 Module 3: Statements and Operators Module 4: Programming constructs Module 5: Arrays.
Module 13: Properties and Indexers. Overview Using Properties Using Indexers.
Introduction to Web Application
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
1 Handling Errors and Exceptions Chapter 6. 2 Objectives You will be able to: 1. Use the try, catch, and finally statements to handle exceptions. 2. Raise.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 4th Edition.
Handling Errors in Web Applications
3 Introduction to Classes and Objects.
Indexer AKEEL AHMED.
CS360 Windows Programming
Module 1: Getting Started
Introduction to C# AKEEL AHMED.
Interfaces.
Classes, Objects, Methods and Strings
Tonga Institute of Higher Education
Presentation transcript:

Module 3: Working with Components

Overview An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating a Simple Console Client Creating an ASP.NET Client

An Introduction to Key.NET Framework Development Technologies Windows Forms Web Forms XML Web Services

 Creating a Simple.NET Framework Component Using Namespaces and Declaring the Class Creating the Class Implementation Implementing Structured Exception Handling Creating a Property Compiling the Component

Using Namespaces and Declaring the Class Create a New Namespace Declare the Class using System; namespace CompCS {...} using System; namespace CompCS {...} public class StringComponent {...}

Creating the Class Implementation Declare a Private Field of Type Array of String Elements Create a Public Default Constructor Assign the stringSet Field to an Array of Strings stringSet = new string[] { "C# String 0", "C# String 1",... }; stringSet = new string[] { "C# String 0", "C# String 1",... }; private string[] stringSet; public StringComponent() {...}

Implementing Structured Exception Handling Implement the GetString Method Create and Throw a New Object of Type IndexOutOfRangeException Exceptions May Be Caught by the Caller in try, catch, finally block Structured Exception Handling Replaces HRESULT-Based Error Handling in COM public string GetString(int index) {...} if((index = stringSet.Length)) { throw new IndexOutOfRangeException(); } return stringSet[index]; if((index = stringSet.Length)) { throw new IndexOutOfRangeException(); } return stringSet[index];

Creating a Property Create a Read-Only Count Property to Get the Number of String Elements in the stringSet Array public int Count { get { return stringSet.Length; } } public int Count { get { return stringSet.Length; } }

Compiling the Component Use the /target:library Switch to Create a DLL Otherwise, an executable with a.dll file extension is created instead of a DLL library csc /out:CompCS.dll /target:library CompCS.cs

Lab 3.1: Creating a.NET Framework Component

 Creating a Simple Console Client Using the Libraries Instantiating the Component Calling the Component Building the Client

Using the Libraries Reference Types Without Having to Fully Qualify the Type Name If Multiple Namespaces Contain the Same Type Name, Create a Namespace Alias to Remove Ambiguity using CompCS; using CompVB; using CompCS; using CompVB; using CSStringComp = CompCS.StringComponent; using VBStringComp = CompVB.StringComponent; using CSStringComp = CompCS.StringComponent; using VBStringComp = CompVB.StringComponent;

Instantiating the Component Declare a Local Variable of Type StringComponent Create a New Instance of the StringComponent Class CompCS.StringComponent myCSStringComp = new CompCS.StringComponent(); CompCS.StringComponent myCSStringComp = new CompCS.StringComponent();

Calling the Component Iterate over All the Members of StringComponent and Output the Strings to the Console for (int index = 0; index < myCSStringComp.Count; index++) { Console.WriteLine (myCSStringComp.GetString(index)); } for (int index = 0; index < myCSStringComp.Count; index++) { Console.WriteLine (myCSStringComp.GetString(index)); }

Building the Client Use the /reference Switch to Reference the Assemblies That Contain the StringComponent Class csc /reference:CompCS.dll,CompVB.dll /out:ClientCS.exe ClientCS.cs csc /reference:CompCS.dll,CompVB.dll /out:ClientCS.exe ClientCS.cs

Lab 3.2: Creating a Simple Console-Based Client

Demonstration: Creating a Windows Forms Client

 Creating an ASP.NET Client Writing the HTML for the ASP.NET Application Coding the Page_Load Event Handler Generating the HTML Response

Multimedia: ASP.NET Execution Model

Writing the HTML for the ASP.NET Application Specify Page-Specific Attributes Within a Page Directive Import the Namespace and the Physical Assembly Specify Code Declaration Blocks... //client code... //client code

Coding the Page_Load Event Handler void Page_Load(Object sender, EventArgs EvArgs) { StringBuilder Out = new StringBuilder(""); int Count = 0; // Iterate over component's strings and concatenate Out.Append("Strings from C# Component "); CompCS.StringComponent myCSStringComp = new CompCS.StringComponent(); for(int index = 0; index < myCSStringComp.Count; index++) { Out.Append(myCSStringComp.GetString(index)); Out.Append(" "); } Message.InnerHtml = Out.ToString(); } void Page_Load(Object sender, EventArgs EvArgs) { StringBuilder Out = new StringBuilder(""); int Count = 0; // Iterate over component's strings and concatenate Out.Append("Strings from C# Component "); CompCS.StringComponent myCSStringComp = new CompCS.StringComponent(); for(int index = 0; index < myCSStringComp.Count; index++) { Out.Append(myCSStringComp.GetString(index)); Out.Append(" "); } Message.InnerHtml = Out.ToString(); }

Generating the HTML Response Specify the Body of the HTML Response

Demonstration: Testing the ASP.NET Client

Lab 3.3: Calling a Component Through an ASP.NET Page

Review An Introduction to Key.NET Framework Development Technologies Creating a Simple.NET Framework Component Creating a Simple Console Client Creating an ASP.NET Client