DEV367 Metro style Apps Core System Services Model Controller View XAML C C++ Desktop Apps HTML / CSS C# VB JavaScript (Chakra) HTML C C++ C# VB Internet Explorer Win32 .NET / SL JavaScript WinRT APIs Communication & Data Graphics & Media Application Model Devices & Printing Windows Core OS Services.

Download Report

Transcript DEV367 Metro style Apps Core System Services Model Controller View XAML C C++ Desktop Apps HTML / CSS C# VB JavaScript (Chakra) HTML C C++ C# VB Internet Explorer Win32 .NET / SL JavaScript WinRT APIs Communication & Data Graphics & Media Application Model Devices & Printing Windows Core OS Services.

DEV367
Metro style Apps
Core
System Services
Model
Controller
View
XAML
C
C++
Desktop Apps
HTML / CSS
C#
VB
JavaScript
(Chakra)
HTML
C
C++
C#
VB
Internet
Explorer
Win32
.NET
/ SL
JavaScript
WinRT APIs
Communication
& Data
Graphics &
Media
Application Model
Devices &
Printing
Windows Core OS Services
Optimized for Metro
BINDINGS TO FOREIGN TYPE SYSTEMS
Key Bindings
Feature
Summary
1. Data Types
ref class
Reference type
value class
Value type
interface class
Interface
property
Property with get/set
event
“Delegate property” with add/remove/raise
delegate
Type-safe function pointer
generic
Type-safe generics
2. Allocation
ref new
Reference-counted allocation
3. Pointer &
Reference
^
Strong pointer (“hat” or “handle”)
%
Strong reference
Person^ p;
{
Person^ p2 = ref new Person();
p2->Name = “John”;
p = p2;
}
p = nullptr;
// refcount = 1
// refcount = 1
// refcount = 2
// refcount = 1
// refcount = 0; ~Person()
public ref class Person {
public: Person(String^ name, String^ email);
void Greet(Person^ other);
internal: ~Person();
void SetPassword(const std::wstring& passwd);
};
Person^ p = ref new Person(“John Surname”);
p->Greet(ref new Person(“Jim Surename”);
public interface class IAnimal {
void Play();
};
public interface class IFeline :
IAnimal {
void Scratch();
};
IAnimal^ animal = ref new Cat();
animal->Play();
ref class Cat : IFeline {
public: virtual void Play();
virtual void Scratch();
};
public ref class DatabaseConnection {
public: ~ DatabaseConnection();
};
{
DatabaseConnection db();
db.SetName( “Employees”);
// …
// … lots of queries, updates, etc. …
// …
} // ~DatabaseConnection()
public: property String^ Name;
public: property Person^ Sibling {
Person^ get() { InitSiblings(); return _sibling; }
void set(Person^ value) { _sibling = value; NotifySibling(); }
}
private: Person^ _sibling;
Person^ p = ref new Person(“John”);
p->Sibling = ref new Person(p->Name);
public delegate void PropertyChanged( String^ propName, String^ propValue );
auto p = ref new PropertyChanged(
[](String^ pn, String^ pv) {
cout << pn << ” = “ << pv;
} );
auto p = ref new PropertyChanged( UIPropertyChanged );
auto p = ref new PropertyChanged( this, MainPage::OnPropertyChanged );
p( “Visible”, false );
public: event PropertyChanged^ OnPropertyChanged;
public: event PropertyChanged^ OnNetworkChanged {
EventRegistrationToken add(PropertyChanged^);
void remove(EventRegistrationToken t);
void raise(String^, String^);
}
person->OnPropertyChanged += propertyChangedDelegate;
auto token = person->OnPropertyChanged::add(propertyChangedDelegate);
person->OnPropertyChanged -= token;
person->OnPropertyChanged::remove(token);
throw ref new InvalidArgumentException();
throw ref new COMException(E_*);
HRESULT
Exception
E_OUTOFMEMORY
OutOfMemoryException
E_INVALIDARG
InvalidArgumentException
E_NOINTERFACE
InvalidCastException
E_POINTER
NullReferenceException
E_NOTIMPL
NotImplementedException
E_ACCESSDENIED
AccessDeniedException
E_FAIL
FailureException
E_BOUNDS
OutOfBoundsException
E_CHANGED_STATE
ChangedStateException
REGDB_E_CLASSNOTREG
ClassNotRegisteredException
try { … } catch (OutOfMemoryException^ ex) { … } E_DISCONNECTED
E_ABORT
ex->HResult
catch (Platform::Exception^)
DisconnectedException
OperationCanceledException
void main() {
try {
ModuleB::Apple();
}
catch (Platform::FailureException^) {
ModuleB::Orange();
}
}
void Pear() {
// perform out-of-bounds operation
}
E_FAIL
E_BOUNDS
void Apple() {
throw ref new
Platform::FailureException();
}
void Orange() {
try {
ModuleA::Pear();
}
catch
(Platform::OutOfBoundsException^) {
}
}
generic<typename T, typename U>
public interface class IPair {
property T First;
property U Second;
};
ref class PairStringUri:
IPair<String^, Uri^> {
public:
property String^ First;
property Uri^ Second;
};
IPair<String^, Uri^>^ uri = GetUri();
auto first = uri->First; // type is String^
auto second = uri->Second; // type is Uri^
#using <Company.Component.winmd>
public
private partial ref class MainPage: UserControl, IComponentConnector
{
public:
void InitializeComponent();
void Connect() { btn1->Click += ref new EventHandler(this, &MainPage::Button_Click); }
};
ref class MainPage
{
public:
MainPage() { InitializeComponent(); }
void Button_Click(Object^ sender, RoutedEventArgs^ e);
};
C++ WinRT Component
Extension SDKs
Application Lifecycle Management Tools for C++ in VS 2012
DEV334: C++ Accelerated Massive Parallelism in Visual C++ 2012
PRC08: C++ in Visual Studio 2012: Modern, Readable, Safe, Fast
http://www.microsoft.com/visualstudio/en-us
Somasegar’s Blog
http://blogs.msdn.com/b/somasegar/
http://blogs.msdn.com/b/jasonz/
http://www.facebook.com/visualstudio
http://twitter.com/#!/visualstudio
http://europe.msteched.com
www.microsoft.com/learning
http://microsoft.com/technet
http://microsoft.com/msdn
http://europe.msteched.com/sessions