Académique Documents
Professionnel Documents
Culture Documents
Desenvolvimento .NET
Paulo Sousa
Instituto Superior de Engenharia do Porto
Instituto Politcnico do Porto
ndice
z
z
z
Plataforma .net
C#
Desenvolvimento
Plataforma .net
Introduo ao desenvolvimento .net
Viso .net
.net framework
z
Plataforma de desenvolvimento
Biblioteca de classes
z
z
C++
C#
Perl
Web Services
Python
User Interface
ASP.NET
COM+
(Transactions, Partitions,
Object Pooling)
Win32
IIS
WMI
CLR
.NET Framework Class Library Support
Thread Support
COM Marshaler
Type Checker
Exception Manager
Security Engine
Debugger
MSIL to Native
Compilers
Code
Manager
Class Loader
Garbage
Collection
Caractersticas CLR
z
z
z
z
z
z
z
z
Mquina virtual
z
z
z
z
z
Standard ECMA
Implementaes CLI
z
Microsoft CLR
Mono (Linux)
Rotor (FreeBSD)
Compilao e Execuo
EXE/DLL
EXE/DLL
(MSIL
(MSILand
and
metadata)
metadata)
Compiler
Compiler
Class
Class Loader
Loader
Class
Class
Libraries
Libraries
(MSIL
(MSILand
and
metadata)
metadata)
JIT
JIT Compiler
Compiler
with
with optional
optional
verification
verification
Trusted,
pre-JITed
code only
Managed
Native
Code
Call to an
uncompiled
method
Execution
Execution
Security
Security Checks
Checks
Runtime Engine
Source
Source
Code
Code
Assembly
z
z
z
z
z
z
Aplicao .net
(Vdeo)
Application Domain
z
z
CTS
z
z
z
z
CTS (2/2)
Value types
z
z
Reference types
z
z
int sp
String cp
20
ol
Garbage Collection
(Vdeo)
Eventos
z
z
z
z
z
Mecanismo de sinalizao
Intrnseco ao framework
extensivamente utilizado internamente
Permite programao assncrona
Publish/subscribe
Componentes .net
z
C#
Introduo ao desenvolvimento .net
Introduo
z
z
z
z
Tudo so objectos
Ficheiros com extenso .cs
Declarao e definio de mtodos no mesmo
ficheiro
Tipos de dados
z
z
z
z
z
z
z
z
object
string
sbyte, short, int, long
byte, ushort, uint, ulong
char
float, double, decimal
bool
Estes tipos so alias para os tipos definidos na
framework
z
Classes e namespaces
z
namespace Demo {
public class MyClass {
...
}
}
Mtodos
z
z
z
Passagem de parmetros
z
z
Por valor
Por referncia
z
z
Herana
z
Herana (2/2)
z
Propriedades
z
Operadores
z
Atribuio
z
Relacionais
z
<
<=
>
>=
==
!=
Lgicos
z
&&
||
Aritmticos
z
z
+ - * / %
+= -= *= /=
++
--
Constantes
z
Pr-definidas
z
z
null
true
false
De utilizador
z
Criao de objectos
// definio da classe
public class MyClass { ... }
// definio da varivel
MyClass obj;
// criao do objecto
obj = new MyClass();
Construtores
z
Arrays
z
// declarao do vector
String[] vec;
// criao do vector
vec = new String[10];
// nmero de elementos pode ser dinmico
vec = new String[n];
Ciclos
// repetio n vezes
for (int x = 0; i < vec.Length; i++)
Console.WriteLine(vec[i]);
// repetio condicional
int i = 0;
while (i < vec.Length)
{
Console.WriteLine(vec[i]);
i++;
}
// enumerao
foreach (String x in vec)
Console.WriteLine(x);
Condicionais
// teste de deciso
if (i < vec.Length)
Console.WriteLine(vec[i]);
else
Console.WriteLine(Erro!!!);
// teste mltiplo
switch (x)
{
case 1: ...; break;
case 2: ...; goto case 3;
case 3: ...; break;
default: ...; break;
}
Interfaces
z
z
z
Implementao de Interfaces
z
Enumerados
z
Fortemente tipados
z
z
structs
z
Benefcios
z
Classes e estruturas
class CPoint { int x, y; ... }
struct SPoint { int x, y; ... }
SPoint sp = new SPoint(10, 20);
CPoint cp = new CPoint(10, 20);
sp
10
20
cp
CPoint
10
10
delegates
z
z
Comentrios XML
class XmlElement
{
/// <summary>
/// Returns the attribute with the given name and
/// namespace</summary>
/// <param name="name">
/// The name of the attribute </param>
/// <param name="ns">
/// The namespace of the attribute, or null if
/// the attribute has no namespace</param>
/// <return>
/// The attribute value, or null if the attribute
/// does not exist</return>
/// <seealso cref=" ="GetAttr(string)"/>
public string GetAttr(string name, string ns) {
... ...
}
}
Desenvolvimento .Net
Introduo ao desenvolvimento .net
IDE
z
Soluo multi-projecto
Multi-linguagem
Multiplos tipos de projecto
Debugger
Gerao de cdigo .net
Gerao de cdigo nativo
z
Demo - Aritmtica
Mais Informao...
z
MSDN Library
z
http://msdn.microsoft.com/vcsharp/
ASP.net
z
http://msdn.microsoft.com/netframework/
C#
z
http://msdn.microsoft.com/library
http://www.asp.net
http://www.dei.isep.ipp.pt/labdotnet/
Mais Informao...
z
Open CLI
z
http://sourceforge.net/projects/ocl
http://www.go-mono.com/
ECMA
z
http://www.ecma-international.org/
Mais Informao...
z
Introduction to C# @ ECMA
z
http://www.ecmainternational.org/activities/Languages/Introdu
ction%20to%20Csharp.pdf
http://www.ecmainternational.org/activities/Languages/ECMA
%20CLI%20Presentation.pdf