.net framework

Download Report

Transcript .net framework

Architektúry softvérových systémov
24.11. Peter Dušek, Gratex
16:00 , DE150
.NET Application
.NET Framework
Operating System + Hardware

Common Language Runtime
Garbage Collection
Code Access Security
Code Verification
Code Execution



Visual Basic, C#, Visual C++, F#
third-party compilers Eiffel, Perl, COBOL
MSIL (Microsoft Intermediate Language)
just-in-time (JIT) compiler
Code in VB.NET
Code in C#
Another
.NET Language
VB.NET compiler
C# compiler
Appropriate
Compiler
IL(Intermediate
Language) code
CLR just-in-time
execution








Triedy
Štruktúry
Číselníky
Rozhrania
Delegáty
Anonymous Types
Lambda Expressions
dynamic

Value types
(Structs, Enumerations, Integral types,
Floating-point types, decimal, bool)

Reference types
(class, interface, delegate, dynamic, object, string)

Pointer types (unsafe context)

Immutable (napr String, DateTime)
K izoláci aplikací sú používáne procesy, ale..
Domény vytvorené hostitelským modulom
runtime
Načítať komponentu aplikácie do domény
Vykonať a uvolniť doménu
CreateDomain
ExecuteAssembly
CreateInstanceAndUnwrap
Unload
[AttributeUsage(AttributeTargets.Method,
Inherited = false, AllowMultiple = true)]
public class YourAttribute : Attribute {
//...
}
public class MyClass
{
[YourAttribute]
public virtual void MyMethod() {
//...
}
}




Reflection provides objects (of type Type)
that describe assemblies, modules and types.
Create instances of objects
Hook up events
Invoke methods

mechanism for communicating between
objects which are not in the same process

Proxy objects are created when a client
activates a remote object.
The proxy object acts as a representative of
the remote object and ensures that all calls
made on the proxy are forwarded to the
correct remote object instance

library for creating lightweight, extensible
applications
príklad

lambda výrazy sú anonymné funkcie, ktoré
môžu obsahovať výrazy a príkazy, a môžu byť
použité na vytvorenie delegátov

operator => is read as "goes to"
int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
int oddNumbers = numbers.Count(n => n % 2 == 1);


public Lazy(LazyExecutionMode mode)
public Lazy(Func<T>
valueFactory,LazyExecutionMode mode)
NotThreadSafe
EnsureSingleThreadSafeExecution
AllowMultipleThreadSafeExecution
ukážka implementácie cez Reflector

XmlSerializer
BinaryFormatter
DataContractSerializer
JSON
XAMLSerializer

ukážka v príkladoch




Výnimky sú spracované bez ohľadu na jazyk,
ktorý generuje výnimky alebo jazyk, ktorý ich
spracováva.
 Spracovanie nevyžaduje žiadnu konkrétnu
jazykovú syntax, ale umožňuje každému jazyku
definovať vlastnú syntax.
 Umožňuje, aby boli výnimky vyvolané aj cez
hranice procesov a dokonca na iné počítače.


udalosť AppDomain.UnhandledException
try
{
}
catch(Exception ex)
{
// throw ex;
}
finaly
{
}
LINQ to Objects
LINQ to SQL
LINQ to XML
LINQ to DataSet
var source = Enumerable.Range(1, 10000);
var evenNums = from num in source
where (num%2) == 0
select num;
SomeDataContext dc = new SomeDataContext();
var queue = from r in dc.Restaurant
where r.Place == “Bratislava”
orderby (r.Ranking, r.Name)
select r;
Ľahšie písanie join-ov na daľšie tabuľky
var queue2 = dc. Restaurant
.Where( r => r.Place == “Bratislava” )
.OrderBy(r => r.Ranking)
.ThenBy(r => r.Name).Skip(10).Take(10);
Obsahuje funkcie, ktoré nemajú ekvivalent v query notation
Single(), First(), Count(), Skip(), Take()

Observer Design Pattern

Implementácia INotifyPropertyChanged

MVVM (model-view-viewModel)

http://www.asp.net/mvc
aktualne verzia 3

ServiceDescription
 ServiceType
 ServiceEndpoint
▪ Endpoint address
▪ Uri, AddressHeader, Identity
▪ Binding – popisuje encoding, security,...
▪ Name, BindingElement
▪ Contract description – popisuje služby servisu
▪ OperationDescription, MessageDescriptions